feat(runtime): default to passthrough and persist execution permissions
This commit is contained in:
@@ -13,7 +13,7 @@ export function gitArguments(root, args, hooksDirectory) {
|
||||
...(hooksDirectory ? ['-c', 'core.hooksPath=' + hooksDirectory] : []), ...args];
|
||||
}
|
||||
|
||||
export function runGit(root, args, { input, env = {}, signal, timeoutMs = 10000, hooksDirectory, maximumBytes = 2 * 1024 * 1024, onSpawn } = {}) {
|
||||
export function runGit(root, args, { input, env = {}, signal, timeoutMs = 0, hooksDirectory, maximumBytes = Infinity, onSpawn } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (signal?.aborted) return reject(signal.reason ?? new Error('Git操作已停止。'));
|
||||
const child = spawn('git', gitArguments(root, args, hooksDirectory), { env: gitEnvironment(env), windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'] });
|
||||
@@ -22,7 +22,7 @@ export function runGit(root, args, { input, env = {}, signal, timeoutMs = 10000,
|
||||
const capture = list => chunk => { bytes += chunk.length; if (bytes > maximumBytes) { exceeded = true; child.kill(); } else list.push(chunk); };
|
||||
child.stdout.on('data', capture(chunks)); child.stderr.on('data', capture(errors));
|
||||
child.stdin.on('error', () => {});
|
||||
const timer = setTimeout(() => { timedOut = true; child.kill(); }, timeoutMs);
|
||||
const timer = timeoutMs > 0 ? setTimeout(() => { timedOut = true; child.kill(); }, timeoutMs) : null;
|
||||
const stop = () => child.kill();
|
||||
signal?.addEventListener('abort', stop, { once: true });
|
||||
child.once('error', error => { clearTimeout(timer); signal?.removeEventListener('abort', stop); reject(error); });
|
||||
|
||||
Reference in New Issue
Block a user