Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | /* eslint camelcase: "off" */
|
---|
| 2 | const isWindows = require('./is-windows.js')
|
---|
| 3 | const setPATH = require('./set-path.js')
|
---|
| 4 | const {resolve} = require('path')
|
---|
| 5 | const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
|
---|
| 6 |
|
---|
| 7 | const makeSpawnArgs = options => {
|
---|
| 8 | const {
|
---|
| 9 | event,
|
---|
| 10 | path,
|
---|
| 11 | scriptShell = isWindows ? process.env.ComSpec || 'cmd' : 'sh',
|
---|
| 12 | env = {},
|
---|
| 13 | stdio,
|
---|
| 14 | cmd,
|
---|
| 15 | stdioString = false,
|
---|
| 16 | } = options
|
---|
| 17 |
|
---|
| 18 | const isCmd = /(?:^|\\)cmd(?:\.exe)?$/i.test(scriptShell)
|
---|
| 19 | const args = isCmd ? ['/d', '/s', '/c', cmd] : ['-c', cmd]
|
---|
| 20 |
|
---|
| 21 | const spawnOpts = {
|
---|
| 22 | env: setPATH(path, {
|
---|
| 23 | // we need to at least save the PATH environment var
|
---|
| 24 | ...process.env,
|
---|
| 25 | ...env,
|
---|
| 26 | npm_package_json: resolve(path, 'package.json'),
|
---|
| 27 | npm_lifecycle_event: event,
|
---|
| 28 | npm_lifecycle_script: cmd,
|
---|
| 29 | npm_config_node_gyp,
|
---|
| 30 | }),
|
---|
| 31 | stdioString,
|
---|
| 32 | stdio,
|
---|
| 33 | cwd: path,
|
---|
| 34 | ...(isCmd ? { windowsVerbatimArguments: true } : {}),
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | return [scriptShell, args, spawnOpts]
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | module.exports = makeSpawnArgs
|
---|
Note:
See
TracBrowser
for help on using the repository browser.