Skip to content

Commit

Permalink
Use npm-run in oder to make it work with installed packages without a…
Browse files Browse the repository at this point in the history
…dding them to `scrtips`. Closes #6
  • Loading branch information
okonet committed Jun 6, 2016
1 parent cb2f479 commit f7b1d9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"pre-commit": "node index.js",
"eslint": "eslint",
"release": "npmpub"
},
"lint-staged": {
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var path = require('path');
var cp = require('child_process');
var npmRun = require('npm-run');
var sgf = require('staged-git-files');
var minimatch = require('minimatch');
var ora = require('ora');
Expand All @@ -8,7 +9,6 @@ var stripEof = require('strip-eof');
var assign = require('object-assign');

var gitBin = which.sync('git');
var npmBin = which.sync('npm');
var root = cp.execSync(gitBin + ' rev-parse --show-toplevel', { encoding: 'utf8' });
var config = require(path.join(stripEof(root), 'package.json'));
var defaultLinters = {};
Expand All @@ -17,8 +17,8 @@ var linters = assign(defaultLinters, customLinters);
var spinner = ora('Starting lint-staged').start();

function runLinter(linter, paths, cb) {
var args = ['run', '-s', linter, '--'].concat(paths);
var npmStream = cp.spawn(npmBin, args, {
var args = ['--'].concat(paths);
var npmStream = npmRun.spawn(linter, args, {
stdio: 'inherit' // <== IMPORTANT: use this option to inherit the parent's environment
});
npmStream.on('error', function(error) {
Expand Down

0 comments on commit f7b1d9f

Please sign in to comment.