MCPcopy Index your code
hub / github.com/ampproject/amphtml / maybeParallelizeCommand

Function maybeParallelizeCommand

build-system/pr-check/parallelization.js:30–42  ·  view source on GitHub ↗

* Splits command execution using a glob string on parallelized CircleCI builds. * * If no parallelization is detected, simply returns the command as-is. * If parallelization is detected, uses the glob to add an argument to the * command by passing it through an optional callback function. * *

(command, glob, callback = (s) => s)

Source from the content-addressed store, hash-verified

28 * @return {string} the CLI command that should be executed.
29 */
30function maybeParallelizeCommand(command, glob, callback = (s) => s) {
31 if (!circleciIsParallelized()) {
32 return command;
33 }
34
35 const tempFileName = tempy.file();
36 timedExecOrDie(
37 `circleci tests glob ${glob} | circleci tests run --command=">${tempFileName} xargs echo -n"`
38 );
39 const globAndRunResults = fs.readFileSync(tempFileName, {encoding: 'utf-8'});
40
41 return `${command} ${callback(globAndRunResults)}`;
42}
43
44module.exports = {maybeParallelizeCommand};

Callers 1

pushBuildWorkflowFunction · 0.85

Calls 2

circleciIsParallelizedFunction · 0.85
callbackFunction · 0.50

Tested by

no test coverage detected