Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗 Replace gulp with the amp task runner #33315

Merged
merged 11 commits into from
Mar 18, 2021
Prev Previous commit
Fix process spawning on Windows
  • Loading branch information
rsimha committed Mar 18, 2021
commit cf8a023d9a981f44a8bd136b682ea50bf1f3da68
7 changes: 5 additions & 2 deletions build-system/common/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ function exec(cmd, options = {'stdio': 'inherit'}) {
}

/**
* Executes the provided shell script in an asynchronous process.
* Executes the provided shell script in an asynchronous process. Special-cases
* the AMP task runner so that it is correctly spawned on all platforms (node
* shebangs do not work on Windows).
*
* @param {string} script
* @param {?Object} options
* @return {!childProcess.ChildProcessWithoutNullStreams}
*/
function execScriptAsync(script, options) {
return childProcess.spawn(script, {shell: shellCmd, ...options});
const scriptToSpawn = script.startsWith('amp ') ? `node ${script}` : script;
return childProcess.spawn(scriptToSpawn, {shell: shellCmd, ...options});
}

/**
Expand Down
5 changes: 4 additions & 1 deletion build-system/common/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ const shellCmd = process.platform == 'win32' ? 'cmd' : '/bin/bash';

/**
* Spawns the given command in a child process with the given options.
* Special-cases the AMP task runner so that it is correctly spawned on all
* platforms (node shebangs do not work on Windows).
*
* @param {string} cmd
* @param {?Object} options
* @return {!Object}
*/
function spawnProcess(cmd, options) {
return childProcess.spawnSync(cmd, {shell: shellCmd, ...options});
const cmdToSpawn = cmd.startsWith('amp ') ? `node ${cmd}` : cmd;
return childProcess.spawnSync(cmdToSpawn, {shell: shellCmd, ...options});
}

/**
Expand Down