From e3882fca0e10a1d79eab4c07cee2f19a6f4d4f3f Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 3 Nov 2016 23:57:40 +0100 Subject: [PATCH] chore: fix binary execution on windows (#1675) Currenlty the `execNodeTask` helper function resolves the binary from the `package.json` and spawns a new process of it. Specifically on Windows this will break, because the Windows Shell does not know how to run the given files (from the Shebang or PATHEXT) Since those binaries are always node binaries we could manually run the node interpreter and run the given JS file as an argument. Closes #1129 --- tools/gulp/task_helpers.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/gulp/task_helpers.ts b/tools/gulp/task_helpers.ts index 9d42388bb85..542ded965b3 100644 --- a/tools/gulp/task_helpers.ts +++ b/tools/gulp/task_helpers.ts @@ -115,7 +115,7 @@ export function execTask(binPath: string, args: string[], options: ExecTaskOptio done(); } }); - } + }; } /** @@ -135,11 +135,13 @@ export function execNodeTask(packageName: string, executable: string | string[], if (err) { done(err); } else { - // Forward to execTask. - execTask(binPath, args, options)(done); + // Execute the node binary within a new child process using spawn. + // The binary needs to be `node` because on Windows the shell cannot determine the correct + // interpreter from the shebang. + execTask('node', [binPath].concat(args), options)(done); } }); - } + }; } @@ -185,7 +187,7 @@ export function vendorTask() { /** Create a task that serves the dist folder. */ -export function serverTask(liveReload: boolean = true, +export function serverTask(liveReload = true, streamCallback: (stream: NodeJS.ReadWriteStream) => void = null) { return () => { const stream = gulp.src('dist').pipe(gulpServer({ @@ -198,7 +200,7 @@ export function serverTask(liveReload: boolean = true, streamCallback(stream); } return stream; - } + }; } @@ -209,5 +211,5 @@ export function sequenceTask(...args: any[]) { ...args, done ); - } + }; }