Skip to content
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

spawn doesn't work on windows (with npm for example) #33

Closed
a-ursino opened this issue Jul 31, 2015 · 12 comments
Closed

spawn doesn't work on windows (with npm for example) #33

a-ursino opened this issue Jul 31, 2015 · 12 comments

Comments

@a-ursino
Copy link

hi when i do
git commit -m "blah blah blah"
with
"pre-commit": [
"npm version"
]
in package.json, it gives me :

executing task "npm" with args "version"
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)

The same thing happens with gulp
"pre-commit": [
"gulp"
]

i think the problem is spawn in windows
maybe this help https://www.npmjs.com/package/cross-spawn

@bahmutov
Copy link
Owner

bahmutov commented Aug 4, 2015

I will look forward to a pull request, don't have access to a windows machine for testing this :(

@bahmutov
Copy link
Owner

Probably need async spawn https://github.com/IndigoUnited/node-cross-spawn-async

@bahmutov
Copy link
Owner

bahmutov commented Mar 6, 2016

try v3.4.1 if it solves the problem. Windows is just not worth the troubles

@bahmutov
Copy link
Owner

Can you try 3.5.2 - this has a fix for Windows were are trying to test out

@a-ursino
Copy link
Author

When i run it (the latest version) with node 5.7.0 it gives me
E:\P\hooks-bot\node_modules\.bin\pre-commit:4 caseuname` in
^^^^

SyntaxError: Unexpected token case
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3
`

with this package.json

"scripts": {
    ...
    "lint": "eslint source test",
    ...
  },
  "pre-commit": [
    "lint"
  ],
  "devDependencies": {
    ...
    "pre-git": "^3.5.4",
    ...
  },

@bahmutov
Copy link
Owner

Could you try pre-git v 3.7.0 please?

@a-ursino
Copy link
Author

Same env like before and when i do the commit

`

git commit -m "ADDED pre-git"
running pre-commit script
executing task "lint"
"lint" non � riconosciuto come comando interno o esterno,
un programma eseguibile o un file batch.

pre-commit You've failed to pass all the hooks.
pre-commit
pre-commit An Error was thrown from command
lint
Error: lint closed with code 1
pre-commit
pre-commit at ChildProcess.onTaskFinished (E:\P\hooks-bot-directio\node_modules\pre-git\src\pre-git.js:170:19)
pre-commit at emitTwo (events.js:105:20)
pre-commit at ChildProcess.emit (events.js:185:7)
pre-commit at maybeClose (internal/child_process.js:827:16)
pre-commit at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
pre-commit
pre-commit You can skip the git hook by running with -n (--no-verify)
pre-commit
pre-commit But this is not advised as your tests are obviously failing.
`

but when i do

`>npm run lint

hooks-bot-directio@1.2.3 lint E:\P\hooks-bot-directio
eslint source test

`

The same thing happens with other comands

@bahmutov
Copy link
Owner

Hmm, with v3.7.0 and the shell path is set correctly? https://github.com/bahmutov/pre-git#windows

@a-ursino
Copy link
Author

Yep. Do you need more info?

@bahmutov
Copy link
Owner

Hmm, if @ybiquitous does not know, then it is up to you, @killanaca to debug and solve this.

@ybiquitous
Copy link
Collaborator

@killanaca

If you change "lint" to "npm run lint" in "pre-commit" as following, does it work well?

package.json:
{
  ...
  "config": {
    "pre-git": {
      "pre-commit": [
-        "lint"
+        "npm run lint"
      ]
    }
  },
  ...
}

@a-ursino
Copy link
Author

yes, now it works ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants