Skip to content

bin: allow file:/// urls to files containing commit messages #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ function loadPatch(uri, cb) {
var h = http
if (~uri.protocol.indexOf('https')) {
h = https
} else if (~uri.protocol.indexOf('file:')) {
return fs.readFile(uri.pathname, (err, data) => {
if (err) return cb(err)
return cb(null, data.toString('utf-8'))
})
}
uri.headers = {
'user-agent': 'core-validate-commit'
Expand Down
5 changes: 5 additions & 0 deletions bin/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ core-validate-commit - Validate the commit message for a particular commit in no
Passing a url to a specific sha on github:

$ core-validate-commit https://api.github.com/repos/nodejs/node/git/commits/9e9d499b8be8ffc6050db25129b042507d7b4b02

Passing a file containing a single commit message:

$ core-validate-commit file:///tmp/commitmsg.txt