Skip to content

Commit

Permalink
child_process: throw exception for batch w/o shell
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Apr 25, 2024
1 parent d5c7ffd commit b64cb6f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/internal/child_process.js
Expand Up @@ -61,6 +61,7 @@ const { isArrayBufferView } = require('internal/util/types');
const spawn_sync = internalBinding('spawn_sync');
const { kStateSymbol } = require('internal/dgram');
const dc = require('diagnostics_channel');
const { extname } = require('path');
const childProcessChannel = dc.channel('child_process');

const {
Expand Down Expand Up @@ -418,7 +419,12 @@ ChildProcess.prototype.spawn = function(options) {

this._handle.close();
this._handle = null;
throw new ErrnoException(err, 'spawn');
const exception = new ErrnoException(err, 'spawn');
const ext = extname(options.file);
if (ext === '.cmd' || ext === '.bat') {
exception.message = '"shell" must be "true" when spawning ' +
'a batch executable';
}
} else {
process.nextTick(onSpawnNT, this);
}
Expand Down

0 comments on commit b64cb6f

Please sign in to comment.