git-commit-file
Advanced tools
Comparing version 1.2.5 to 1.2.6
@@ -6,11 +6,23 @@ #!/usr/bin/env node | ||
const args = yargs.argv._ | ||
let arg | ||
process.env.NODE_IS_GLOBAL = true | ||
const argv = yargs.argv | ||
const args = argv._ | ||
let filename | ||
if (args.length) { | ||
arg = args[0] | ||
filename = args[0] | ||
} | ||
process.env.NODE_IS_GLOBAL = true | ||
let commitMessage = argv.message || argv.m | ||
if (commitMessage == null && args.length > 1) commitMessage = args[1] | ||
main(arg) | ||
if (typeof filename === 'number') filename = filename.toString() | ||
if (typeof commitMessage === 'number') commitMessage = commitMessage.toString() | ||
// console.log(filename, typeof filename) | ||
// console.log(commitMessage, typeof commitMessage) | ||
// process.exit(0) | ||
main(filename, commitMessage) |
const gcf = require('./js/gcf') | ||
const main = filename => { | ||
gcf(filename) | ||
const main = (filename, commitMessage) => { | ||
gcf(filename, commitMessage) | ||
} | ||
module.exports = main |
const helper = require('./helper') | ||
const {name} = require('../package.json') | ||
const gcf = filename => { | ||
const gcf = (filename, commitMessage) => { | ||
@@ -15,2 +15,3 @@ const errors = {} | ||
if (typeof filename !== 'string') throw TypeError(`${name} expects a string`) | ||
if (typeof commitMessage !== 'string') commitMessage = 'Updated ' + filename | ||
@@ -21,3 +22,3 @@ cmdObj = helper.gitAdd(filename) | ||
cmdObj = helper.gitCommit(filename) | ||
cmdObj = helper.gitCommit(filename, commitMessage) | ||
count += cmdObj.code | ||
@@ -24,0 +25,0 @@ if (cmdObj.stderr) errors.commit = cmdObj.stderr |
@@ -38,3 +38,3 @@ const chai = require('chai') | ||
expect(addStub).to.have.been.calledWith(filename) | ||
expect(commitStub).to.have.been.calledWith(filename) | ||
expect(commitStub).to.have.been.calledWith(filename, 'Updated ' + filename) | ||
@@ -72,2 +72,22 @@ expect(greenSpy).to.have.been.calledWith(`Committed ${filename}`) | ||
}) | ||
it('can commit with custom message', () => { | ||
const filename = 'myFile' | ||
const commitMessage = 'herro' | ||
initStubs({}) | ||
const exitCode = gcf(filename, commitMessage) | ||
expect(commitStub).to.have.been.calledWith(filename, commitMessage) | ||
expect(exitCode).to.equal(0) | ||
}) | ||
it('can commit with custom message when using webpack', () => { | ||
const filename = 'myFile' | ||
const commitMessage = 'herro' | ||
initStubs({webpack: filename}) | ||
const exitCode = gcf(null, commitMessage) | ||
expect(commitStub).to.have.been.calledWith(filename, commitMessage) | ||
expect(exitCode).to.equal(0) | ||
}) | ||
}) | ||
@@ -81,3 +101,3 @@ | ||
expect(addStub).to.have.been.calledWith(filename) | ||
expect(commitStub).to.have.been.calledWith(filename) | ||
expect(commitStub).to.have.been.calledWith(filename, 'Updated ' + filename) | ||
@@ -117,3 +137,3 @@ expect(yellowSpy).to.have.been.calledWith(`Did not commit ${filename}`) | ||
expect(addStub).to.have.been.calledWith(filename) | ||
expect(commitStub).to.have.been.calledWith(filename) | ||
expect(commitStub).to.have.been.calledWith(filename, 'Updated ' + filename) | ||
@@ -120,0 +140,0 @@ expect(redSpy).to.have.been.calledWith(`Did not commit ${filename}`, expectedErrors) |
@@ -26,4 +26,4 @@ const chalk = require('chalk') | ||
// Do not use string interpolation here | ||
gitCommit /* istanbul ignore next */ /**/(filename) { | ||
return exec('git commit -m "Updated ' + filename + '" ' + filename, {silent: true}) | ||
gitCommit /* istanbul ignore next */ /**/(filename, commitMessage) { | ||
return exec('git commit -m "' + commitMessage + '" ' + filename, {silent: true}) | ||
}, | ||
@@ -30,0 +30,0 @@ |
{ | ||
"name": "git-commit-file", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "Git add and commit a single file in a single command", | ||
@@ -5,0 +5,0 @@ "author": "danday74", |
@@ -42,7 +42,8 @@ # git-commit-file (gcf) | ||
``` bash | ||
gcf README.md # add and commit README.md | ||
gcf ./myFile.js # add and commit myFile.js | ||
gcf myDir/myFile.js # add and commit myDir/myFile.js | ||
gcf ./myDir/myFile.js # add and commit myDir/myFile.js | ||
gcf # add and commit the file referenced by `output.filename` in your webpack config | ||
gcf README.md # add and commit README.md | ||
gcf -m 'my message' README.md # add and commit README.md with custom commit message | ||
gcf ./myFile.js # add and commit myFile.js | ||
gcf myDir/myFile.js # add and commit myDir/myFile.js | ||
gcf ./myDir/myFile.js # add and commit myDir/myFile.js | ||
gcf # add and commit the file referenced by `output.filename` in your webpack config | ||
``` | ||
@@ -52,4 +53,6 @@ | ||
The default commit message is `Updated <filename>` but you can override with the `-m` or `--message` flag. | ||
<br> | ||
@@ -64,7 +67,8 @@ | ||
let exitCode | ||
exitCode = gcf('myFile.js') // add and commit myFile.js | ||
exitCode = gcf('./myFile.js') // add and commit myFile.js | ||
exitCode = gcf('myDir/myFile.js') // add and commit myDir/myFile.js | ||
exitCode = gcf('./myDir/myFile.js') // add and commit myDir/myFile.js | ||
exitCode = gcf() // add and commit the file referenced by `output.filename` in your webpack config | ||
exitCode = gcf('README.md') // add and commit README.md | ||
exitCode = gcf('README.md', 'my message') // add and commit README.md with custom commit message | ||
exitCode = gcf('./myFile.js') // add and commit myFile.js | ||
exitCode = gcf('myDir/myFile.js') // add and commit myDir/myFile.js | ||
exitCode = gcf('./myDir/myFile.js') // add and commit myDir/myFile.js | ||
exitCode = gcf() // add and commit the file referenced by `output.filename` in your webpack config | ||
``` | ||
@@ -77,7 +81,8 @@ | ||
"scripts": { | ||
"commit1": "gcf myFile.js", | ||
"commit2": "git-commit-file ./myFile.js", | ||
"commit3": "gcf myDir/myFile.js", | ||
"commit4": "gitcommitfile ./myDir/myFile.js", | ||
"commit5": "gitCommitFile" | ||
"commit1": "git-commit-file README.md", | ||
"commit2": "git-commit-file -m 'my message' README.md", | ||
"commit3": "git-commit-file ./myFile.js", | ||
"commit4": "git-commit-file myDir/myFile.js", | ||
"commit5": "git-commit-file ./myDir/myFile.js", | ||
"commit6": "gcf" | ||
} | ||
@@ -84,0 +89,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73451
209
111