| Server IP : 68.183.124.220 / Your IP : 216.73.216.141 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/happymandarin/node_modules/execa/ |
Upload File : |
'use strict';
var childProcess = require('child_process');
var crossSpawnAsync = require('cross-spawn-async');
var stripEof = require('strip-eof');
var objectAssign = require('object-assign');
var npmRunPath = require('npm-run-path');
var pathKey = require('path-key')();
var TEN_MEBIBYTE = 1024 * 1024 * 10;
function handleArgs(cmd, args, opts) {
var parsed;
if (opts && opts.__winShell === true) {
delete opts.__winShell;
parsed = {
command: cmd,
args: args,
options: opts,
file: cmd,
original: cmd
};
} else {
parsed = crossSpawnAsync._parse(cmd, args, opts);
}
opts = objectAssign({
maxBuffer: TEN_MEBIBYTE,
stripEof: true,
preferLocal: true,
encoding: 'utf8'
}, parsed.options);
if (opts.preferLocal) {
opts.env = objectAssign({}, opts.env || process.env);
opts.env[pathKey] = npmRunPath({
cwd: opts.cwd,
path: opts.env[pathKey]
});
}
return {
cmd: parsed.command,
args: parsed.args,
opts: opts
};
}
function handleOutput(opts, val) {
if (opts.stripEof) {
val = stripEof(val);
}
return val;
}
module.exports = function (cmd, args, opts) {
var spawned;
var promise = new Promise(function (resolve, reject) {
var parsed = handleArgs(cmd, args, opts);
spawned = childProcess.execFile(parsed.cmd, parsed.args, parsed.opts, function (err, stdout, stderr) {
if (err) {
err.stdout = stdout;
err.stderr = stderr;
err.message += stdout;
reject(err);
return;
}
resolve({
stdout: handleOutput(parsed.opts, stdout),
stderr: handleOutput(parsed.opts, stderr)
});
});
crossSpawnAsync._enoent.hookChildProcess(spawned, parsed);
});
promise.kill = spawned.kill.bind(spawned);
promise.pid = spawned.pid;
return promise;
};
module.exports.shell = function (cmd, opts) {
var file;
var args;
opts = objectAssign({}, opts);
if (process.platform === 'win32') {
opts.__winShell = true;
file = process.env.comspec || 'cmd.exe';
args = ['/s', '/c', '"' + cmd + '"'];
opts.windowsVerbatimArguments = true;
} else {
file = '/bin/sh';
args = ['-c', cmd];
}
if (opts.shell) {
file = opts.shell;
}
return module.exports(file, args, opts);
};
module.exports.spawn = function (cmd, args, opts) {
var parsed = handleArgs(cmd, args, opts);
var spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts);
crossSpawnAsync._enoent.hookChildProcess(spawned, parsed);
return spawned;
};
module.exports.sync = function (cmd, args, opts) {
var parsed = handleArgs(cmd, args, opts);
var out = childProcess.execFileSync(parsed.cmd, parsed.args, parsed.opts);
return handleOutput(parsed.opts, out);
};