forked from npm/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
npm-run: fix commands with whitespaces on windows
Fixes npm#4403
- Loading branch information
1 parent
10a2867
commit 80282ed
Showing
7 changed files
with
103 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
var test = require('tap').test | ||
var path = require('path') | ||
var npm = path.resolve(__dirname, '../../cli.js') | ||
var pkg = __dirname + '/scripts-whitespace-windows' | ||
var tmp = pkg + '/tmp' | ||
var cache = pkg + '/cache' | ||
var modules = pkg + '/node_modules' | ||
var dep = pkg + '/dep' | ||
|
||
var mkdirp = require('mkdirp') | ||
var rimraf = require('rimraf') | ||
var node = process.execPath | ||
var spawn = require('child_process').spawn | ||
|
||
test('setup', function (t) { | ||
mkdirp.sync(cache) | ||
mkdirp.sync(tmp) | ||
rimraf.sync(modules) | ||
|
||
var env = { | ||
npm_config_cache: cache, | ||
npm_config_tmp: tmp, | ||
npm_config_prefix: pkg, | ||
npm_config_global: 'false' | ||
} | ||
|
||
var child = spawn(node, [npm, 'i', dep], { | ||
cwd: pkg, | ||
env: env | ||
}) | ||
|
||
child.stdout.setEncoding('utf8') | ||
child.stderr.on('data', function(chunk) { | ||
throw new Error('got stderr data: ' + JSON.stringify('' + chunk)) | ||
}) | ||
child.on('close', function () { | ||
t.end() | ||
}) | ||
}) | ||
|
||
test('test', function (t) { | ||
|
||
var child = spawn(node, [npm, 'run', 'foo'], { | ||
cwd: pkg, | ||
env: process.env | ||
}) | ||
|
||
child.stdout.setEncoding('utf8') | ||
child.stderr.on('data', function(chunk) { | ||
throw new Error('got stderr data: ' + JSON.stringify('' + chunk)) | ||
}) | ||
child.stdout.on('data', ondata) | ||
child.on('close', onend) | ||
var c = '' | ||
function ondata (chunk) { | ||
c += chunk | ||
} | ||
function onend () { | ||
c = c.trim() | ||
|
||
t.ok(/npm-test-fine/.test(c)) | ||
t.end() | ||
} | ||
}) | ||
|
||
test('cleanup', function (t) { | ||
rimraf.sync(cache) | ||
rimraf.sync(tmp) | ||
rimraf.sync(modules) | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Hi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Hi! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
if (process.argv.length === 8) | ||
console.log('npm-test-fine') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "scripts-whitespace-windows-dep", | ||
"version": "0.0.1", | ||
"bin": [ "bin/foo" ], | ||
"repository": "git://github.com/robertkowalski/bogusfixture" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "scripts-whitespace-windows", | ||
"scripts": { | ||
"foo": "foo --title \"Analysis of\" --recurse -d report src" | ||
}, | ||
"description": "a test", | ||
"repository": "git://github.com/robertkowalski/bogus", | ||
"dependencies": { | ||
"scripts-whitespace-windows-dep": "0.0.1" | ||
} | ||
} |