nyc 3.0.1 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +2 -0
- package/CHANGELOG.md +10 -0
- package/README.md +5 -0
- package/bin/nyc.js +10 -1
- package/index.js +77 -34
- package/node_modules/foreground-child/.npmignore +3 -0
- package/node_modules/foreground-child/.travis.yml +6 -0
- package/node_modules/foreground-child/LICENSE +15 -0
- package/node_modules/foreground-child/README.md +33 -0
- package/node_modules/foreground-child/index.js +54 -0
- package/node_modules/foreground-child/node_modules/win-spawn/.npmignore +15 -0
- package/node_modules/foreground-child/node_modules/win-spawn/README.md +41 -0
- package/node_modules/foreground-child/node_modules/win-spawn/bin/win-spawn +12 -0
- package/node_modules/foreground-child/node_modules/win-spawn/index.js +64 -0
- package/node_modules/foreground-child/node_modules/win-spawn/package.json +45 -0
- package/node_modules/foreground-child/package.json +40 -0
- package/node_modules/foreground-child/test/basic.js +150 -0
- package/node_modules/spawn-wrap/.travis.yml +8 -0
- package/node_modules/spawn-wrap/LICENSE +15 -0
- package/node_modules/spawn-wrap/README.md +62 -0
- package/node_modules/spawn-wrap/index.js +225 -0
- package/node_modules/spawn-wrap/lib/is-windows.js +5 -0
- package/node_modules/spawn-wrap/lib/win-rebase.js +7 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/index.js +24 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/license +21 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/package.json +70 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/readme.md +33 -0
- package/node_modules/spawn-wrap/package.json +41 -0
- package/node_modules/spawn-wrap/shim.js +139 -0
- package/node_modules/spawn-wrap/t.js +26 -0
- package/node_modules/spawn-wrap/test/basic.js +139 -0
- package/node_modules/spawn-wrap/test/fixtures/script.js +3 -0
- package/node_modules/spawn-wrap/test/win-rebase.js +20 -0
- package/package.json +12 -6
- package/test/fixtures/not-loaded.js +2 -0
- package/test/nyc-test.js +46 -3
package/.npmignore
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### v3.2.2 (2015/09/11 22:02 -07:00)
|
|
4
|
+
|
|
5
|
+
- [#47](https://github.com/bcoe/nyc/pull/47) make the default exclude rules work on Windows (@bcoe)
|
|
6
|
+
- [#45](https://github.com/bcoe/nyc/pull/45) pull in patched versions of spawn-wrap and foreground-child, which support Windows (@bcoe)
|
|
7
|
+
- [#44](https://github.com/bcoe/nyc/pull/44) Adds --all option which adds 0% coverage reports for all files in project, regardless of whether code touches them (@ronkorving)
|
|
8
|
+
|
|
9
|
+
### v3.1.0 (2015/08/02 19:04 +00:00)
|
|
10
|
+
|
|
11
|
+
- [#38](https://github.com/bcoe/nyc/pull/38) fixes for windows spawning (@rmg)
|
|
12
|
+
|
|
3
13
|
### v3.0.1 (2015/07/25 20:51 +00:00)
|
|
4
14
|
- [#33](https://github.com/bcoe/nyc/pull/33) spawn istanbul in a way that is less likely to break npm@3.x (@bcoe)
|
|
5
15
|
|
package/README.md
CHANGED
|
@@ -95,6 +95,11 @@ adding the following configuration:
|
|
|
95
95
|
}}
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
## Include Reports For Files That Are Not Required
|
|
99
|
+
|
|
100
|
+
By default nyc does not collect coverage for files that have not
|
|
101
|
+
been required, run nyc with the flag `--all` to enable this.
|
|
102
|
+
|
|
98
103
|
## Configuring Istanbul
|
|
99
104
|
|
|
100
105
|
Behind the scenes nyc uses [istanbul](https://www.npmjs.com/package/istanbul). You
|
package/bin/nyc.js
CHANGED
|
@@ -66,6 +66,12 @@ if (process.env.NYC_CWD) {
|
|
|
66
66
|
type: 'boolean',
|
|
67
67
|
describe: "don't output a report after tests finish running"
|
|
68
68
|
})
|
|
69
|
+
.option('a', {
|
|
70
|
+
alias: 'all',
|
|
71
|
+
default: false,
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
describe: 'whether or not to instrument all files of the project (not just the ones touched by your test suite)'
|
|
74
|
+
})
|
|
69
75
|
.help('h')
|
|
70
76
|
.alias('h', 'help')
|
|
71
77
|
.version(require('../package.json').version)
|
|
@@ -81,8 +87,9 @@ if (process.env.NYC_CWD) {
|
|
|
81
87
|
report(argv)
|
|
82
88
|
} else if (~argv._.indexOf('check-coverage')) {
|
|
83
89
|
foreground(
|
|
84
|
-
|
|
90
|
+
process.execPath,
|
|
85
91
|
[
|
|
92
|
+
require.resolve('istanbul/lib/cli'),
|
|
86
93
|
'check-coverage',
|
|
87
94
|
'--lines=' + argv.lines,
|
|
88
95
|
'--functions=' + argv.functions,
|
|
@@ -96,6 +103,8 @@ if (process.env.NYC_CWD) {
|
|
|
96
103
|
var nyc = (new NYC())
|
|
97
104
|
nyc.cleanup()
|
|
98
105
|
|
|
106
|
+
if (argv.all) nyc.addAllFiles()
|
|
107
|
+
|
|
99
108
|
sw([__filename], {
|
|
100
109
|
NYC_CWD: process.cwd()
|
|
101
110
|
})
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* global __coverage__ */
|
|
2
2
|
var _ = require('lodash')
|
|
3
3
|
var fs = require('fs')
|
|
4
|
+
var glob = require('glob')
|
|
4
5
|
var mkdirp = require('mkdirp')
|
|
5
6
|
var path = require('path')
|
|
6
7
|
var rimraf = require('rimraf')
|
|
@@ -24,15 +25,14 @@ function NYC (opts) {
|
|
|
24
25
|
var config = require(path.resolve(this.cwd, './package.json')).config || {}
|
|
25
26
|
config = config.nyc || {}
|
|
26
27
|
|
|
27
|
-
this.exclude = config.exclude || ['node_modules
|
|
28
|
+
this.exclude = config.exclude || ['node_modules[\/\\\\]', 'test[\/\\\\]', 'test\\.js']
|
|
28
29
|
if (!Array.isArray(this.exclude)) this.exclude = [this.exclude]
|
|
29
30
|
this.exclude = _.map(this.exclude, function (p) {
|
|
30
31
|
return new RegExp(p)
|
|
31
32
|
})
|
|
32
33
|
|
|
33
34
|
this.instrumenter = this._createInstrumenter()
|
|
34
|
-
|
|
35
|
-
mkdirp.sync(this.tmpDirectory())
|
|
35
|
+
this._createOutputDirectory()
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
NYC.prototype._createInstrumenter = function () {
|
|
@@ -50,53 +50,75 @@ NYC.prototype._createInstrumenter = function () {
|
|
|
50
50
|
})
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
NYC.prototype.
|
|
54
|
-
|
|
53
|
+
NYC.prototype.addFile = function (filename, returnImmediately) {
|
|
54
|
+
var instrument = true
|
|
55
|
+
var relFile = path.relative(this.cwd, filename)
|
|
56
|
+
|
|
57
|
+
// only instrument a file if it's not on the exclude list.
|
|
58
|
+
for (var i = 0, exclude; (exclude = this.exclude[i]) !== undefined; i++) {
|
|
59
|
+
if (exclude.test(relFile)) {
|
|
60
|
+
if (returnImmediately) return {}
|
|
61
|
+
instrument = false
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var content = stripBom(fs.readFileSync(filename, 'utf8'))
|
|
67
|
+
|
|
68
|
+
if (instrument) {
|
|
69
|
+
content = this.instrumenter.instrumentSync(content, './' + relFile)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
instrument: instrument,
|
|
74
|
+
content: content,
|
|
75
|
+
relFile: relFile
|
|
76
|
+
}
|
|
55
77
|
}
|
|
56
78
|
|
|
57
|
-
NYC.prototype.
|
|
79
|
+
NYC.prototype.addAllFiles = function () {
|
|
58
80
|
var _this = this
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
require.extensions['.js'] = function (module, filename) {
|
|
62
|
-
var instrument = true
|
|
63
|
-
var content = fs.readFileSync(filename, 'utf8')
|
|
82
|
+
this._createOutputDirectory()
|
|
64
83
|
|
|
65
|
-
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (instrument) {
|
|
72
|
-
content = _this.instrumenter.instrumentSync(
|
|
73
|
-
content,
|
|
74
|
-
'./' + relFile
|
|
84
|
+
glob.sync('**/*.js', {nodir: true}).forEach(function (filename) {
|
|
85
|
+
var obj = _this.addFile(filename, true)
|
|
86
|
+
if (obj.instrument) {
|
|
87
|
+
module._compile(
|
|
88
|
+
_this.instrumenter.getPreamble(obj.content, obj.relFile),
|
|
89
|
+
filename
|
|
75
90
|
)
|
|
76
91
|
}
|
|
92
|
+
})
|
|
77
93
|
|
|
78
|
-
|
|
94
|
+
this.writeCoverageFile()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
NYC.prototype._wrapRequire = function () {
|
|
98
|
+
var _this = this
|
|
99
|
+
|
|
100
|
+
// any JS you require should get coverage added.
|
|
101
|
+
require.extensions['.js'] = function (module, filename) {
|
|
102
|
+
var obj = _this.addFile(filename)
|
|
103
|
+
module._compile(obj.content, filename)
|
|
79
104
|
}
|
|
80
105
|
}
|
|
81
106
|
|
|
107
|
+
NYC.prototype.cleanup = function () {
|
|
108
|
+
if (!process.env.NYC_CWD) rimraf.sync(this.tmpDirectory())
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
NYC.prototype._createOutputDirectory = function () {
|
|
112
|
+
mkdirp.sync(this.tmpDirectory())
|
|
113
|
+
}
|
|
114
|
+
|
|
82
115
|
NYC.prototype._wrapExit = function () {
|
|
83
116
|
var _this = this
|
|
84
|
-
var outputCoverage = function () {
|
|
85
|
-
var coverage = global.__coverage__
|
|
86
|
-
if (typeof __coverage__ === 'object') coverage = __coverage__
|
|
87
|
-
if (!coverage) return
|
|
88
|
-
|
|
89
|
-
fs.writeFileSync(
|
|
90
|
-
path.resolve(_this.tmpDirectory(), './', process.pid + '.json'),
|
|
91
|
-
JSON.stringify(coverage),
|
|
92
|
-
'utf-8'
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
117
|
|
|
96
118
|
// we always want to write coverage
|
|
97
119
|
// regardless of how the process exits.
|
|
98
120
|
onExit(function () {
|
|
99
|
-
|
|
121
|
+
_this.writeCoverageFile()
|
|
100
122
|
}, {alwaysLast: true})
|
|
101
123
|
}
|
|
102
124
|
|
|
@@ -106,6 +128,18 @@ NYC.prototype.wrap = function (bin) {
|
|
|
106
128
|
return this
|
|
107
129
|
}
|
|
108
130
|
|
|
131
|
+
NYC.prototype.writeCoverageFile = function () {
|
|
132
|
+
var coverage = global.__coverage__
|
|
133
|
+
if (typeof __coverage__ === 'object') coverage = __coverage__
|
|
134
|
+
if (!coverage) return
|
|
135
|
+
|
|
136
|
+
fs.writeFileSync(
|
|
137
|
+
path.resolve(this.tmpDirectory(), './', process.pid + '.json'),
|
|
138
|
+
JSON.stringify(coverage),
|
|
139
|
+
'utf-8'
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
109
143
|
NYC.prototype.report = function (cb, _collector, _reporter) {
|
|
110
144
|
cb = cb || function () {}
|
|
111
145
|
|
|
@@ -145,8 +179,17 @@ NYC.prototype.tmpDirectory = function () {
|
|
|
145
179
|
|
|
146
180
|
NYC.prototype.mungeArgs = function (yargv) {
|
|
147
181
|
var argv = process.argv.slice(1)
|
|
182
|
+
argv = argv.slice(argv.indexOf(yargv._[0]))
|
|
183
|
+
if (!/^(node|iojs)$/.test(argv[0]) &&
|
|
184
|
+
process.platform === 'win32' &&
|
|
185
|
+
(/\.js$/.test(argv[0]) ||
|
|
186
|
+
(!/\.(cmd|exe)$/.test(argv[0]) &&
|
|
187
|
+
!fs.existsSync(argv[0] + '.cmd') &&
|
|
188
|
+
!fs.existsSync(argv[0] + '.exe')))) {
|
|
189
|
+
argv.unshift(process.execPath)
|
|
190
|
+
}
|
|
148
191
|
|
|
149
|
-
return argv
|
|
192
|
+
return argv
|
|
150
193
|
}
|
|
151
194
|
|
|
152
195
|
module.exports = NYC
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
The ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# foreground-child
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/isaacs/foreground-child)
|
|
4
|
+
|
|
5
|
+
Run a child as if it's the foreground process. Give it stdio. Exit
|
|
6
|
+
when it exits.
|
|
7
|
+
|
|
8
|
+
Mostly this module is here to support some use cases around wrapping
|
|
9
|
+
child processes for test coverage and such.
|
|
10
|
+
|
|
11
|
+
## USAGE
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
var foreground = require('foreground-child')
|
|
15
|
+
|
|
16
|
+
// cats out this file
|
|
17
|
+
var child = foreground('cat', [__filename])
|
|
18
|
+
|
|
19
|
+
// At this point, it's best to just do nothing else.
|
|
20
|
+
// return or whatever.
|
|
21
|
+
// If the child gets a signal, or just exits, then this
|
|
22
|
+
// parent process will exit in the same way.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A callback can optionally be provided, if you want to perform an action
|
|
26
|
+
before your foreground-child exits:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
var child = foreground('cat', [__filename], function (done) {
|
|
30
|
+
// perform an action.
|
|
31
|
+
return done()
|
|
32
|
+
})
|
|
33
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var signalExit = require('signal-exit')
|
|
2
|
+
var spawn = require('win-spawn')
|
|
3
|
+
|
|
4
|
+
module.exports = function (program, args, cb) {
|
|
5
|
+
var arrayIndex = arguments.length
|
|
6
|
+
|
|
7
|
+
if (typeof args === 'function') {
|
|
8
|
+
cb = args
|
|
9
|
+
args = undefined
|
|
10
|
+
} else {
|
|
11
|
+
cb = Array.prototype.slice.call(arguments).filter(function (arg, i) {
|
|
12
|
+
if (typeof arg === 'function') {
|
|
13
|
+
arrayIndex = i
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
})[0]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
cb = cb || function (done) {
|
|
20
|
+
return done()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (Array.isArray(program)) {
|
|
24
|
+
args = program.slice(1)
|
|
25
|
+
program = program[0]
|
|
26
|
+
} else if (!Array.isArray(args)) {
|
|
27
|
+
args = [].slice.call(arguments, 1, arrayIndex)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var child = spawn(program, args, { stdio: 'inherit' })
|
|
31
|
+
|
|
32
|
+
var childExited = false
|
|
33
|
+
signalExit(function (code, signal) {
|
|
34
|
+
child.kill(signal || 'SIGHUP')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
child.on('close', function (code, signal) {
|
|
38
|
+
cb(function () {
|
|
39
|
+
childExited = true
|
|
40
|
+
if (signal) {
|
|
41
|
+
// If there is nothing else keeping the event loop alive,
|
|
42
|
+
// then there's a race between a graceful exit and getting
|
|
43
|
+
// the signal to this process. Put this timeout here to
|
|
44
|
+
// make sure we're still alive to get the signal, and thus
|
|
45
|
+
// exit with the intended signal code.
|
|
46
|
+
setTimeout(function () {}, 200)
|
|
47
|
+
process.kill(process.pid, signal)
|
|
48
|
+
} else
|
|
49
|
+
process.exit(code)
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return child
|
|
54
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# win-spawn
|
|
2
|
+
|
|
3
|
+
Spawn for node.js but in a way that works regardless of which OS you're using. Use this if you want to use spawn with a JavaScript file. It works by explicitly invoking node on windows. It also shims support for environment variable setting by attempting to parse the command with a regex. Since all modification is wrapped in `if (os === 'Windows_NT')` it can be safely used on non-windows systems and will not break anything.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
$ npm install win-spawn
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Command Line
|
|
12
|
+
|
|
13
|
+
All the following will work exactly as if the 'win-spawn ' prefix was ommitted when on unix.
|
|
14
|
+
|
|
15
|
+
$ win-spawn foo
|
|
16
|
+
$ win-spawn ./bin/foo
|
|
17
|
+
$ win-spawn NODE_PATH=./lib foo
|
|
18
|
+
$ win-spawn NODE_PATH=./lib foo arg1 arg2
|
|
19
|
+
|
|
20
|
+
You can also transform all the line endings in a directory from `\r\n` to `\n` just by running:
|
|
21
|
+
|
|
22
|
+
$ win-line-endings
|
|
23
|
+
|
|
24
|
+
You can preview the changes by running:
|
|
25
|
+
|
|
26
|
+
$ win-line-endings -p
|
|
27
|
+
|
|
28
|
+
It will ignore `node_modules` and `.git` by default, but is not clever enough to recognise binary files yet.
|
|
29
|
+
|
|
30
|
+
### API
|
|
31
|
+
|
|
32
|
+
This will just pass through to `child_process.spawn` on unix systems, but will correctly parse the arguments on windows.
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
spawn('foo', [], {stdio: 'inherit'});
|
|
36
|
+
spawn('./bin/foo', [], {stdio: 'inherit'});
|
|
37
|
+
spawn('NODE_PATH=./lib foo', [], {stdio: 'inherit'});
|
|
38
|
+
spawn('NODE_PATH=./lib foo', [arg1, arg2], {stdio: 'inherit'});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+

|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var spawn = require('../index.js');
|
|
4
|
+
|
|
5
|
+
var args = process.argv.slice(2);
|
|
6
|
+
var cmd = '';
|
|
7
|
+
while (/^[A-Z_]+\=[^ \=]+$/.test(args[0])) {
|
|
8
|
+
cmd += args.shift() + ' ';
|
|
9
|
+
}
|
|
10
|
+
cmd += args.shift();
|
|
11
|
+
|
|
12
|
+
spawn(cmd, args, { stdio: 'inherit' });
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var cSpawn = require('child_process').spawn;
|
|
2
|
+
var os = require('os').type();
|
|
3
|
+
|
|
4
|
+
exports = module.exports = spawn;
|
|
5
|
+
function spawn(command, args, options) {
|
|
6
|
+
if (os === 'Windows_NT') {
|
|
7
|
+
command = command.replace(/\//g, '\\');
|
|
8
|
+
|
|
9
|
+
if (command === 'rm') {
|
|
10
|
+
command = 'rmdir';
|
|
11
|
+
if (args[0] === '-rf' || args[0] == '-fr') {
|
|
12
|
+
args[0] = '/q';
|
|
13
|
+
args.unshift('/s');
|
|
14
|
+
}
|
|
15
|
+
if (args[0] === '-f') {
|
|
16
|
+
args[0] = '/q';
|
|
17
|
+
}
|
|
18
|
+
if (args[0] === '-r') {
|
|
19
|
+
args[0] = '/s';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
args = args || [];
|
|
23
|
+
options = options || {};
|
|
24
|
+
var match, matchA;
|
|
25
|
+
if (matchA = /((?:[A-Z_]+\=[^ \=]+ )+)?([^\r\n]+)/.exec(command)) {
|
|
26
|
+
try {
|
|
27
|
+
var file = require('fs').readFileSync(matchA[2], 'utf8');
|
|
28
|
+
if (match = /\#\!\/usr\/bin\/env ([^\r\n]+)/.exec(file)) {
|
|
29
|
+
args.unshift(matchA[2]);
|
|
30
|
+
command = (matchA[1] || '') + match[1];
|
|
31
|
+
}
|
|
32
|
+
} catch (ex) { }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (match = /((?:[A-Z_]+\=[^ \=]+ )+)([^\r\n]+)/.exec(command)) {
|
|
36
|
+
command = match[2];
|
|
37
|
+
|
|
38
|
+
options.env = options.env || shallowClone(process.env);
|
|
39
|
+
|
|
40
|
+
var env = match[1].split(' ');
|
|
41
|
+
env.forEach(function (v) {
|
|
42
|
+
v = v.split('=');
|
|
43
|
+
if (v.length === 2) {
|
|
44
|
+
options.env[v[0]] = v[1];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
args.unshift(command);
|
|
50
|
+
args.unshift('/c');
|
|
51
|
+
args.unshift('/d');
|
|
52
|
+
command = 'cmd';
|
|
53
|
+
}
|
|
54
|
+
return cSpawn(command, args, options);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function shallowClone(obj) {
|
|
58
|
+
var out = {};
|
|
59
|
+
Object.keys(obj)
|
|
60
|
+
.forEach(function (key) {
|
|
61
|
+
out[key] = obj[key];
|
|
62
|
+
});
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "win-spawn",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Spawn for node.js but in a way that works regardless of which OS you're using",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/ForbesLindesay/win-spawn.git"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"win-spawn": "./bin/win-spawn"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"linify": "~1.0.1"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"prepublish": "linify transform bin"
|
|
18
|
+
},
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "ForbesLindesay"
|
|
21
|
+
},
|
|
22
|
+
"license": "BSD",
|
|
23
|
+
"readme": "# win-spawn\n\n Spawn for node.js but in a way that works regardless of which OS you're using. Use this if you want to use spawn with a JavaScript file. It works by explicitly invoking node on windows. It also shims support for environment variable setting by attempting to parse the command with a regex. Since all modification is wrapped in `if (os === 'Windows_NT')` it can be safely used on non-windows systems and will not break anything.\n\n## Installation\n\n $ npm install win-spawn\n\n## Usage\n\n### Command Line\n\n All the following will work exactly as if the 'win-spawn ' prefix was ommitted when on unix.\n\n $ win-spawn foo\n $ win-spawn ./bin/foo\n $ win-spawn NODE_PATH=./lib foo\n $ win-spawn NODE_PATH=./lib foo arg1 arg2\n\n You can also transform all the line endings in a directory from `\\r\\n` to `\\n` just by running:\n\n $ win-line-endings\n\n You can preview the changes by running:\n\n $ win-line-endings -p\n\n It will ignore `node_modules` and `.git` by default, but is not clever enough to recognise binary files yet.\n\n### API\n\nThis will just pass through to `child_process.spawn` on unix systems, but will correctly parse the arguments on windows.\n\n```javascript\nspawn('foo', [], {stdio: 'inherit'});\nspawn('./bin/foo', [], {stdio: 'inherit'});\nspawn('NODE_PATH=./lib foo', [], {stdio: 'inherit'});\nspawn('NODE_PATH=./lib foo', [arg1, arg2], {stdio: 'inherit'});\n```\n\n\n",
|
|
24
|
+
"readmeFilename": "README.md",
|
|
25
|
+
"_id": "win-spawn@2.0.0",
|
|
26
|
+
"dist": {
|
|
27
|
+
"shasum": "397a29130ec98d0aa0bc86baa4621393effd0b07",
|
|
28
|
+
"tarball": "http://registry.npmjs.org/win-spawn/-/win-spawn-2.0.0.tgz"
|
|
29
|
+
},
|
|
30
|
+
"_from": "win-spawn@>=2.0.0 <3.0.0",
|
|
31
|
+
"_npmVersion": "1.2.10",
|
|
32
|
+
"_npmUser": {
|
|
33
|
+
"name": "forbeslindesay",
|
|
34
|
+
"email": "forbes@lindesay.co.uk"
|
|
35
|
+
},
|
|
36
|
+
"maintainers": [
|
|
37
|
+
{
|
|
38
|
+
"name": "forbeslindesay",
|
|
39
|
+
"email": "forbes@lindesay.co.uk"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"directories": {},
|
|
43
|
+
"_shasum": "397a29130ec98d0aa0bc86baa4621393effd0b07",
|
|
44
|
+
"_resolved": "https://registry.npmjs.org/win-spawn/-/win-spawn-2.0.0.tgz"
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "foreground-child",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Run a child as if it's the foreground process. Give it stdio. Exit when it exits.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"directories": {
|
|
7
|
+
"test": "test"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"signal-exit": "^2.0.0",
|
|
11
|
+
"win-spawn": "^2.0.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"tap": "^1.2.1"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "tap --coverage test/*.js"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/isaacs/foreground-child.git"
|
|
22
|
+
},
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "Isaac Z. Schlueter",
|
|
25
|
+
"email": "i@izs.me",
|
|
26
|
+
"url": "http://blog.izs.me/"
|
|
27
|
+
},
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/isaacs/foreground-child/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/isaacs/foreground-child#readme",
|
|
33
|
+
"gitHead": "ad7ba1d4a84e8b199cbfb5d30e01e586390978cc",
|
|
34
|
+
"readme": "# foreground-child\n\n[](https://travis-ci.org/isaacs/foreground-child)\n\nRun a child as if it's the foreground process. Give it stdio. Exit\nwhen it exits.\n\nMostly this module is here to support some use cases around wrapping\nchild processes for test coverage and such.\n\n## USAGE\n\n```js\nvar foreground = require('foreground-child')\n\n// cats out this file\nvar child = foreground('cat', [__filename])\n\n// At this point, it's best to just do nothing else.\n// return or whatever.\n// If the child gets a signal, or just exits, then this\n// parent process will exit in the same way.\n```\n\nA callback can optionally be provided, if you want to perform an action\nbefore your foreground-child exits:\n\n```js\nvar child = foreground('cat', [__filename], function (done) {\n // perform an action.\n return done()\n})\n```\n",
|
|
35
|
+
"readmeFilename": "README.md",
|
|
36
|
+
"_id": "foreground-child@1.3.0",
|
|
37
|
+
"_shasum": "709eb362a23a7befd3ba349fddfc7168957831d5",
|
|
38
|
+
"_from": "git+https://github.com/bcoe/foreground-child.git#win-spawn",
|
|
39
|
+
"_resolved": "git+https://github.com/bcoe/foreground-child.git#ad7ba1d4a84e8b199cbfb5d30e01e586390978cc"
|
|
40
|
+
}
|