Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed for windows.

  • Loading branch information...
commit fe3313f3f3e063f1e19470b6b31835ca6c76bc1b 1 parent c97580a
@beefsack authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/exec.js
View
14 lib/exec.js
@@ -2,18 +2,24 @@ module.exports = exec
var npm = require("./npm.js")
, output = require("./utils/output.js")
+ , cp = require("child_process")
+ , os = require("os")
exec.usage = "npm exec <command>\n(execute command using local package bin)"
exec.completion = require("./utils/completion/local-bin.js")
function exec (args, cb) {
- var b = npm.bin
- , exec = require("child_process").exec
+ var b = npm.bin, cmd
if (args.length == 0) return cb("Usage:\n"+exec.usage)
- var cmd = "PATH=" + b + ":$PATH " + args.join(" ")
- exec(cmd, function (error, stdout, stderr) {
+ var cmd;
+ if (process.platform.match(/win/))
+ cmd = "SET OLDPATH=%PATH% & SET PATH=" + b + ";%PATH% & " +
+ args.join(" ") + " & SET PATH=%OLDPATH%"
+ else
+ cmd = "PATH=" + b + ":$PATH " + args.join(" ")
+ cp.exec(cmd, function (error, stdout, stderr) {
if (error !== null) return cb(stderr.replace(/\n$/, ''))
var o = stdout.replace(/\n$/, '')
output.write(o, function (er) { cb(er, o) })

0 comments on commit fe3313f

Please sign in to comment.
Something went wrong with that request. Please try again.