Skip to content

Use the /q flag with cmd.exe #135

Open
@zenflow

Description

@zenflow

Is this an nodejs issue we can solve here in userland?

nodejs/node#27120 - Use the /q flag with cmd.exe in child_process.spawn()

I think it makes sense to add the flag by default here (in cross-spawn), without any option, even if it won't be done by default in Node.js child_process because it prevents a "special" Windows behavior (i.e. printing an extra line like D:\foo\bar>echo hello to the console as the initial output nodejs/node#27120 (comment)).

Node.js core needs to make it optional since some user some time might want to use this Windows-only behavior, but cross-spawn doesn't have that burden.

Execa simply prepends the /q flag to the parsed args like this:

https://github.com/sindresorhus/execa/blob/717d29d539e0bdf1666c1a4bc10fa406d996e7b3/index.js#L28-L56

	const parsed = crossSpawn._parse(file, args, options);
	file = parsed.command;
	args = parsed.args;
	options = parsed.options;
        // ... mutations to `options` ...
	if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
		// #116
		args.unshift('/q');
	}
        // ... calls Node.js `child_process.spawn` with file, args, options ...

Referenced issue: sindresorhus/execa#116

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions