Skip to content

Commit e3882fc

Browse files
devversionjelbourn
authored andcommitted
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
1 parent 93f8e04 commit e3882fc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tools/gulp/task_helpers.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function execTask(binPath: string, args: string[], options: ExecTaskOptio
115115
done();
116116
}
117117
});
118-
}
118+
};
119119
}
120120

121121
/**
@@ -135,11 +135,13 @@ export function execNodeTask(packageName: string, executable: string | string[],
135135
if (err) {
136136
done(err);
137137
} else {
138-
// Forward to execTask.
139-
execTask(binPath, args, options)(done);
138+
// Execute the node binary within a new child process using spawn.
139+
// The binary needs to be `node` because on Windows the shell cannot determine the correct
140+
// interpreter from the shebang.
141+
execTask('node', [binPath].concat(args), options)(done);
140142
}
141143
});
142-
}
144+
};
143145
}
144146

145147

@@ -185,7 +187,7 @@ export function vendorTask() {
185187

186188

187189
/** Create a task that serves the dist folder. */
188-
export function serverTask(liveReload: boolean = true,
190+
export function serverTask(liveReload = true,
189191
streamCallback: (stream: NodeJS.ReadWriteStream) => void = null) {
190192
return () => {
191193
const stream = gulp.src('dist').pipe(gulpServer({
@@ -198,7 +200,7 @@ export function serverTask(liveReload: boolean = true,
198200
streamCallback(stream);
199201
}
200202
return stream;
201-
}
203+
};
202204
}
203205

204206

@@ -209,5 +211,5 @@ export function sequenceTask(...args: any[]) {
209211
...args,
210212
done
211213
);
212-
}
214+
};
213215
}

0 commit comments

Comments
 (0)