Merge pull request +10025 from c9/localfs-env

wait for reading env before calling spawn
pull/223/head
Lennart Kats 2015-11-05 12:28:38 +01:00
commit c6421a0820
1 zmienionych plików z 11 dodań i 0 usunięć

11
node_modules/vfs-local/localfs.js wygenerowano vendored
Wyświetl plik

@ -130,8 +130,12 @@ module.exports = function setup(fsOptions) {
}
// Fetch environment variables from the login shell
var waitForEnv = null;
if (!isWin) {
waitForEnv = [];
_execFile(BASH, ["-lc", "printenv -0"], function(error, stdout, stderr) {
var pending = waitForEnv;
waitForEnv = null;
if (!error && !stderr && stdout) {
var env = fsOptions.defaultEnv;
stdout.split("\x00").forEach(function(entry) {
@ -140,6 +144,7 @@ module.exports = function setup(fsOptions) {
env[entry.slice(0, i)] = entry.slice(i + 1);
});
}
pending.forEach(function(x) { x(); });
});
}
@ -1447,6 +1452,9 @@ module.exports = function setup(fsOptions) {
}
function spawn(executablePath, options, callback) {
if (waitForEnv)
return waitForEnv.push(spawn.bind(null, executablePath, options, callback));
var args = options.args || [];
_setDefaultEnv(options);
@ -2166,6 +2174,9 @@ module.exports = function setup(fsOptions) {
}
function execFile(executablePath, options, callback) {
if (waitForEnv)
return waitForEnv.push(execFile.bind(null, executablePath, options, callback));
if (isWin && execFileWin(executablePath, options, callback))
return;