1 | 'use strict';
|
2 |
|
3 | var sync = require('spawn-sync');
|
4 | var crossSpawn = require('cross-spawn-async');
|
5 | var parse = require('cross-spawn-async/lib/parse');
|
6 | var enoent = require('cross-spawn-async/lib/enoent');
|
7 | var resolveCommand = require('cross-spawn-async/lib/resolveCommand');
|
8 |
|
9 | var isWin = process.platform === 'win32';
|
10 | var isNode10 = process.version.indexOf('v0.10.') === 0;
|
11 |
|
12 | function verifySyncENOENT(status, parsed) {
|
13 |
|
14 | var err = enoent.verifyENOENT(status, parsed, 'spawnSync');
|
15 |
|
16 | if (err) {
|
17 | return err;
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 | if (isNode10 && status === -1) {
|
23 | parsed.file = isWin ? parsed.file : resolveCommand(parsed.original);
|
24 |
|
25 | if (!parsed.file) {
|
26 | err = enoent.notFoundError(parsed.original, 'spawnSync');
|
27 | }
|
28 | }
|
29 |
|
30 | return err;
|
31 | }
|
32 |
|
33 | function spawn(command, args, options) {
|
34 | return crossSpawn.spawn(command, args, options);
|
35 | }
|
36 |
|
37 | function spawnSync(command, args, options) {
|
38 | var parsed;
|
39 | var result;
|
40 |
|
41 |
|
42 | parsed = parse(command, args, options);
|
43 |
|
44 |
|
45 | result = sync(parsed.command, parsed.args, parsed.options);
|
46 |
|
47 |
|
48 | result.error = result.error || verifySyncENOENT(result.status, parsed);
|
49 |
|
50 | return result;
|
51 | }
|
52 |
|
53 | module.exports = spawn;
|
54 | module.exports.spawn = spawn;
|
55 | module.exports.sync = spawnSync;
|