lint-staged
Advanced tools
Comparing version 3.2.2 to 3.2.3
{ | ||
"name": "lint-staged", | ||
"version": "3.2.2", | ||
"description": "Lint files staged by git", | ||
@@ -10,15 +9,20 @@ "main": "index.js", | ||
"scripts": { | ||
"postinstall": "echo \"lint-staged installed! Do not forget to configure it. See https://github.com/okonet/lint-staged/blob/master/README.md\" && exit 0", | ||
"postinstall": "echo \"🚫💩 lint-staged installed! \nDo not forget to configure it. See https://github.com/okonet/lint-staged/blob/master/README.md\" && exit 0", | ||
"lint": "eslint .", | ||
"lint:fix": "npm run lint -- --fix", | ||
"pre-commit": "node index.js", | ||
"release": "npmpub", | ||
"test": "mocha --compilers js:babel-register ./test/*.spec.js", | ||
"deps": "npm-check -s", | ||
"deps:update": "npm-check -u" | ||
"deps:update": "npm-check -u", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"pre-commit": "pre-commit", | ||
"greenkeeper": { | ||
"ignore": [ | ||
"cosmiconfig" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/okonet/lint-staged.git" | ||
"url": "https://github.com/okonet/lint-staged.git" | ||
}, | ||
@@ -68,6 +72,6 @@ "keywords": [ | ||
"npm-check": "^5.2.2", | ||
"npmpub": "^3.1.0", | ||
"pre-commit": "^1.1.3", | ||
"rewire": "^2.5.1", | ||
"tmp": "^0.0.29" | ||
"semantic-release": "^6.3.2", | ||
"tmp": "^0.0.31" | ||
}, | ||
@@ -78,3 +82,4 @@ "config": { | ||
} | ||
} | ||
} | ||
}, | ||
"version": "3.2.3" | ||
} |
@@ -47,3 +47,7 @@ /* global process */ | ||
title: `Running tasks for ${ task.pattern }`, | ||
task: () => (new Listr(runScript(task.commands, task.fileList, packageJson))) | ||
task: () => ( | ||
new Listr( | ||
runScript(task.commands, task.fileList, packageJson, gitDir) | ||
) | ||
) | ||
})) | ||
@@ -50,0 +54,0 @@ |
@@ -6,4 +6,5 @@ 'use strict' | ||
module.exports = function runScript(commands, pathsToLint, packageJson) { | ||
module.exports = function runScript(commands, pathsToLint, packageJson, gitDir) { | ||
const lintersArray = Array.isArray(commands) ? commands : [commands] | ||
const execaOptions = gitDir ? { cwd: gitDir } : {} | ||
return lintersArray.map(linter => ({ | ||
@@ -15,3 +16,3 @@ title: linter, | ||
return new Promise((resolve, reject) => { | ||
execa(res.bin, res.args) | ||
execa(res.bin, res.args, execaOptions) | ||
.then(() => { | ||
@@ -18,0 +19,0 @@ resolve(`${ linter } passed!`) |
@@ -60,3 +60,3 @@ /* eslint no-underscore-dangle: 0 */ | ||
expect(spy.calls[0].arguments).toEqual( | ||
['npm', ['run', '--silent', 'test', '--', 'test.js']] | ||
['npm', ['run', '--silent', 'test', '--', 'test.js'], {}] | ||
) | ||
@@ -67,6 +67,23 @@ | ||
expect(spy.calls[1].arguments).toEqual( | ||
['npm', ['run', '--silent', 'test2', '--', 'test.js']] | ||
['npm', ['run', '--silent', 'test2', '--', 'test.js'], {}] | ||
) | ||
}) | ||
it('should pass cwd option to execa if gitDir option is set', () => { | ||
const spy = expect.createSpy() | ||
runScript.__set__('execa', spy) | ||
const res = runScript(['test', 'test2'], 'test.js', packageJSON, '../') | ||
expect(res[0].task()).toBeAPromise() | ||
expect(spy.calls.length).toEqual(1) | ||
expect(spy.calls[0].arguments).toEqual( | ||
['npm', ['run', '--silent', 'test', '--', 'test.js'], { cwd: '../' }] | ||
) | ||
expect(res[1].task()).toBeAPromise() | ||
expect(spy.calls.length).toEqual(2) | ||
expect(spy.calls[1].arguments).toEqual( | ||
['npm', ['run', '--silent', 'test2', '--', 'test.js'], { cwd: '../' }] | ||
) | ||
}) | ||
}) | ||
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
33008
26
427