Skip to content

Commit 7de0051

Browse files
committed
fix windows cli output when exiting
fixes microsoft#17343
1 parent be6f0f7 commit 7de0051

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

scripts/code-cli.bat

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@echo off
2+
setlocal
3+
4+
title VSCode Dev
5+
6+
pushd %~dp0\..
7+
8+
:: Node modules
9+
if not exist node_modules call .\scripts\npm.bat install
10+
11+
for /f "tokens=2 delims=:," %%a in ('findstr /R /C:"\"nameShort\":.*" product.json') do set NAMESHORT=%%~a
12+
set NAMESHORT=%NAMESHORT: "=%
13+
set NAMESHORT=%NAMESHORT:"=%.exe
14+
set CODE=".build\electron\%NAMESHORT%"
15+
16+
for /f "tokens=2 delims=:," %%a in ('findstr /R /C:"\"electronVersion\":.*" package.json') do set DESIREDVERSION=%%~a
17+
set DESIREDVERSION=%DESIREDVERSION: "=%
18+
set DESIREDVERSION=v%DESIREDVERSION:"=%
19+
if exist .\.build\electron\version (set /p INSTALLEDVERSION=<.\.build\electron\version) else (set INSTALLEDVERSION="")
20+
21+
:: Get electron
22+
if not exist %CODE% node .\node_modules\gulp\bin\gulp.js electron
23+
if not "%INSTALLEDVERSION%" == "%DESIREDVERSION%" node .\node_modules\gulp\bin\gulp.js electron
24+
25+
:: Build
26+
if not exist out node .\node_modules\gulp\bin\gulp.js compile
27+
28+
:: Configuration
29+
set ELECTRON_RUN_AS_NODE=1
30+
set NODE_ENV=development
31+
set VSCODE_DEV=1
32+
set ELECTRON_DEFAULT_ERROR_MODE=1
33+
set ELECTRON_ENABLE_LOGGING=1
34+
set ELECTRON_ENABLE_STACK_DUMPING=1
35+
36+
:: Launch Code
37+
%CODE% --debug=5874 out\cli.js . %*
38+
popd
39+
40+
endlocal

src/vs/code/node/cli.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ export function main(argv: string[]): TPromise<void> {
7373
return TPromise.as(null);
7474
}
7575

76+
function eventuallyExit(code: number): void {
77+
setTimeout(() => process.exit(code), 0);
78+
}
79+
7680
main(process.argv)
77-
.then(() => process.exit(0))
81+
.then(() => eventuallyExit(0))
7882
.then(null, err => {
7983
console.error(err.stack ? err.stack : err);
80-
process.exit(1);
84+
eventuallyExit(1);
8185
});

0 commit comments

Comments
 (0)