Reputation: 4004
I'm trying to run the command git branch | grep \*
like so:
require('child_process').exec('git branch | grep \*', function(err){
console.log(err);
});
but I keep getting the error { [Error: Command failed: ] killed: false, code: 1, signal: null }
Why is this happening and how can I do this?
Upvotes: 0
Views: 1460
Reputation: 549
It means grep return code is 1 and grep got nothing.
You can just write a simple code that return 1 and run it by exec in node.js and you will get the same result as above.
You can check the status code by err.code, and do something like reporting empty result in your callback function.
Upvotes: 1
Reputation: 729
Are you trying to run grep \*
? remember you have to escape backslashes in strings.
Upvotes: 1