folder picker: a PowerShell that ends before its window opens (security software) falls back to typing the path (#3831)
This commit is contained in:
1 parent
47ccec7c6a
commit
ea897551ee
2 files changed
+9
-2
No files matched your search
@@ -62,7 +62,10 @@ export function watchedWindowsDialog(shell, args, { readyMs = 30_000, openMs = 2
|
||||
const later = () => { clearTimeout(timer); ready = true; setTimeout(() => end(resolve, { stdout: '' }), openMs).unref?.(); };
|
||||
child.stdout?.on('data', chunk => { stdout += chunk; if (!ready && /^READY\s*$/m.test(stdout)) { clearTimeout(timer); later(); } });
|
||||
child.on('error', error => end(reject, error));
|
||||
child.on('close', code => { if (settled) return; settled = true; clearTimeout(timer); code === 0 ? resolve({ stdout }) : reject(Object.assign(new Error('exit ' + code), { code })); });
|
||||
child.on('close', code => { if (settled) return; settled = true; clearTimeout(timer);
|
||||
// PowerShell ended before its window opened (security software ended it, #3831): the person types the path instead.
|
||||
if (!ready) return resolve({ noDialog: true });
|
||||
code === 0 ? resolve({ stdout }) : reject(Object.assign(new Error('exit ' + code), { code })); });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -170,5 +170,9 @@ test('Windows: a PowerShell that is missing or fails is reported as before', asy
|
||||
f.child.emit('error', Object.assign(new Error('x'), { code: 'ENOENT' }));
|
||||
await assert.rejects(missing, e => e.code === 'ENOENT');
|
||||
const g = fakeShell(); const failed = watchedWindowsDialog('powershell.exe', [], { spawnProcess: g.spawnProcess });
|
||||
g.child.emit('close', 1); await assert.rejects(failed, e => e.code === 1);
|
||||
g.child.emit('close', 1);
|
||||
// Ended by security software before any window opened (#3831): the app asks for the path instead of an error.
|
||||
assert.deepEqual(await failed, { noDialog: true });
|
||||
const h = fakeShell(); const late = watchedWindowsDialog('powershell.exe', [], { spawnProcess: h.spawnProcess });
|
||||
h.child.stdout.emit('data', 'READY\n'); h.child.emit('close', 1); await assert.rejects(late, e => e.code === 1);
|
||||
});
|
||||
Reference in new issue
Block a user