diff --git a/packages/cli/src/commands/RunProjectCommand.ts b/packages/cli/src/commands/RunProjectCommand.ts index 9ed56daf7324..3df505a03547 100644 --- a/packages/cli/src/commands/RunProjectCommand.ts +++ b/packages/cli/src/commands/RunProjectCommand.ts @@ -29,15 +29,13 @@ export class RunProjectCommand implements CommandModule { * @inheritDoc */ async handler(args: ArgumentsCamelCase) { - let cmd = ''; + const env = { ...process.env }; if (!args.purge) { - cmd += 'CRAWLEE_PURGE_ON_START=0 '; + env.CRAWLEE_PURGE_ON_START = '0'; } // TODO detect the right package manager (e.g. based on package.json's `packageManager` field) - cmd += `npm run ${args.script}`; - - execSync(cmd, { stdio: 'inherit' }); + execSync(`npm run ${args.script}`, { stdio: 'inherit', env }); } }