From 7707e9efe6aaddbd902823f549510cf584a151ca Mon Sep 17 00:00:00 2001 From: james Date: Sat, 22 Nov 2014 12:04:30 -0600 Subject: [PATCH] fixing windows spawn bug --- fenestrate.js | 8 +++++++- package.json | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fenestrate.js b/fenestrate.js index 02acdcb..83e1c5a 100644 --- a/fenestrate.js +++ b/fenestrate.js @@ -23,6 +23,7 @@ var fs = require('fs'), cmdArgs = process.argv.slice(2), cmd = cmdArgs.shift(), modulePath = cmdArgs.shift(), + windows = /^win/.test(process.platform), helpText = fs.readFileSync(path.resolve(__dirname, './README.md'), 'utf-8').split('').shift(), dependencyTypes = ["dependencies","devDependencies"]; @@ -78,10 +79,15 @@ function flattenDependencies(declared, resolved, depType) { function reinstallNodeModules(p, prod, cb) { rimraf(path.resolve(p, "./node_modules"), function(err) { + + var cmd = prod ? "npm install --production" : "npm install", + args = ((windows ? "cmd /c " : "") + cmd).split(' '); + if (err) { cb(err); } else { - childProcess.spawn('npm', prod ? ['install','--production'] : ['install'], { cwd: p, stdio: 'inherit' }).on('close', function(code) { + + childProcess.spawn(args[0], args.slice(1), { cwd: p, stdio: 'inherit' }).on('close', function(code) { cb(null, code); }); } diff --git a/package.json b/package.json index 9a67349..798f0fd 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "title": "fenestrate", "author": "James Zetlen", "description": "Flatten the dependency tree of an NPM module so it can fit into the Windows 260-character path limitation.", - "version": "0.1.1", + "version": "0.2.0", "bin": { "fenestrate": "./bin/fenestrate" }, @@ -12,6 +12,7 @@ "url": "https://github.com/zetlen/fenestrate.git" }, "dependencies": { + "minimist": "^1.1.0", "rimraf": "^2.2.8" }, "main": "./fenestrate",