Skip to content

Commit d6d2daa

Browse files
authored
Update samples.ts
1 parent b6d4188 commit d6d2daa

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tools/gulp/tasks/samples.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { blue, magenta } from 'ansis';
22
import * as childProcess from 'child_process';
3+
import { execFile as execFileCb } from 'child_process';
34
import * as log from 'fancy-log';
45
import { task } from 'gulp';
56
import { resolve } from 'path';
@@ -8,6 +9,7 @@ import { samplePath } from '../config';
89
import { containsPackageJson, getDirs } from '../util/task-helpers';
910

1011
const exec = promisify(childProcess.exec);
12+
const execFile = promisify(execFileCb);
1113

1214
async function executeNpmScriptInSamples(
1315
script: string,
@@ -78,12 +80,17 @@ async function executeNPMScriptInDirectory(
7880
const dirName = dir.replace(resolve(__dirname, '../../../'), '');
7981
log.info(`Running ${blue(script)} in ${magenta(dirName)}`);
8082
try {
81-
const result = await exec(
82-
`${script} --prefix ${dir} ${appendScript ? '-- ' + appendScript : ''}`,
83-
);
84-
// const result = await exec(`npx npm-check-updates -u`, {
85-
// cwd: join(process.cwd(), dir),
86-
// });
83+
// Split the script into command and arguments
84+
const scriptParts = script.split(' ').filter(Boolean);
85+
const command = scriptParts[0];
86+
const args = scriptParts.slice(1);
87+
// Add --prefix and dir
88+
args.push('--prefix', dir);
89+
// If appendScript is provided, split and append
90+
if (appendScript) {
91+
args.push('--', ...appendScript.split(' ').filter(Boolean));
92+
}
93+
const result = await execFile(command, args);
8794

8895
log.info(`Finished running ${blue(script)} in ${magenta(dirName)}`);
8996
if (result.stderr) {

0 commit comments

Comments
 (0)