Skip to content

Commit

Permalink
fix: Fix cli-command-parser to parse arguments for execa
Browse files Browse the repository at this point in the history
Fixes #419
  • Loading branch information
Andrey Okonetchnikov authored and okonet committed Apr 3, 2018
1 parent 50bda07 commit b4fbc3b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
"node": ">=6"
},
"bin": "index.js",
"files": [
"index.js",
"src"
],
"files": ["index.js", "src"],
"scripts": {
"precommit": "node index.js",
"cz": "git-cz",
Expand All @@ -30,6 +27,7 @@
"dependencies": {
"app-root-path": "^2.0.1",
"chalk": "^2.3.1",
"cli-command-parser": "^1.0.3",
"commander": "^2.14.1",
"cosmiconfig": "^4.0.0",
"debug": "^3.1.0",
Expand Down Expand Up @@ -70,9 +68,7 @@
},
"jest": {
"testEnvironment": "node",
"setupFiles": [
"./testSetup.js"
]
"setupFiles": ["./testSetup.js"]
},
"keywords": [
"lint",
Expand Down
3 changes: 2 additions & 1 deletion src/findBin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const parse = require('cli-command-parser')
const appRoot = require('app-root-path')
const npmWhich = require('npm-which')(process.cwd())
const checkPkgScripts = require('./checkPkgScripts')
Expand All @@ -23,7 +24,7 @@ module.exports = function findBin(cmd) {
* "*.js": "eslint"
* }
*/
const [binName, ...args] = cmd.split(' ')
const [binName, ...args] = parse(cmd)

if (cache.has(binName)) {
debug('Resolving binary for `%s` from cache', binName)
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/findBin.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ WARN \`lint-staged\` no longer supports running scripts defined in package.json.
The same behavior can be achieved by changing the command to any of the following:
- \`npm run lint -- \`
- \`eslint . \`"
- \`yarn lint:base -- . \`"
`;
4 changes: 2 additions & 2 deletions test/findBin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('findBin', () => {
})

it('should parse cmd and add arguments to args', () => {
const { bin, args } = findBin('my-linter task --fix')
const { bin, args } = findBin('my-linter task --fix --string "additional argument"')
expect(bin).toEqual('my-linter')
expect(args).toEqual(['task', '--fix'])
expect(args).toEqual(['task', '--fix', '--string', 'additional argument'])
})
})
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,10 @@ class-utils@^0.3.5:
isobject "^3.0.0"
static-extend "^0.1.1"

cli-command-parser@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/cli-command-parser/-/cli-command-parser-1.0.3.tgz#377af3ce60ad2d8a34a7e5eae4b395d491b0d652"

cli-cursor@^1.0.1, cli-cursor@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987"
Expand Down

0 comments on commit b4fbc3b

Please sign in to comment.