mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
Update samples.ts
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { blue, magenta } from 'ansis';
|
import { blue, magenta } from 'ansis';
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'child_process';
|
||||||
|
import { execFile as execFileCb } from 'child_process';
|
||||||
import * as log from 'fancy-log';
|
import * as log from 'fancy-log';
|
||||||
import { task } from 'gulp';
|
import { task } from 'gulp';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
@@ -8,6 +9,7 @@ import { samplePath } from '../config';
|
|||||||
import { containsPackageJson, getDirs } from '../util/task-helpers';
|
import { containsPackageJson, getDirs } from '../util/task-helpers';
|
||||||
|
|
||||||
const exec = promisify(childProcess.exec);
|
const exec = promisify(childProcess.exec);
|
||||||
|
const execFile = promisify(execFileCb);
|
||||||
|
|
||||||
async function executeNpmScriptInSamples(
|
async function executeNpmScriptInSamples(
|
||||||
script: string,
|
script: string,
|
||||||
@@ -78,12 +80,17 @@ async function executeNPMScriptInDirectory(
|
|||||||
const dirName = dir.replace(resolve(__dirname, '../../../'), '');
|
const dirName = dir.replace(resolve(__dirname, '../../../'), '');
|
||||||
log.info(`Running ${blue(script)} in ${magenta(dirName)}`);
|
log.info(`Running ${blue(script)} in ${magenta(dirName)}`);
|
||||||
try {
|
try {
|
||||||
const result = await exec(
|
// Split the script into command and arguments
|
||||||
`${script} --prefix ${dir} ${appendScript ? '-- ' + appendScript : ''}`,
|
const scriptParts = script.split(' ').filter(Boolean);
|
||||||
);
|
const command = scriptParts[0];
|
||||||
// const result = await exec(`npx npm-check-updates -u`, {
|
const args = scriptParts.slice(1);
|
||||||
// cwd: join(process.cwd(), dir),
|
// Add --prefix and dir
|
||||||
// });
|
args.push('--prefix', dir);
|
||||||
|
// If appendScript is provided, split and append
|
||||||
|
if (appendScript) {
|
||||||
|
args.push('--', ...appendScript.split(' ').filter(Boolean));
|
||||||
|
}
|
||||||
|
const result = await execFile(command, args);
|
||||||
|
|
||||||
log.info(`Finished running ${blue(script)} in ${magenta(dirName)}`);
|
log.info(`Finished running ${blue(script)} in ${magenta(dirName)}`);
|
||||||
if (result.stderr) {
|
if (result.stderr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user