Description
Hi and thanks for this great package which works perfectly for me when running powershell or cmd processes under Windows.
I am getting troubles when trying to run powershell with command line parameters.
It seems that by default, the spawn method sanitize arguments.
So, for instance, if i try to run the following code :
const { platform } = require('os');
const path = require('path');
const Promise = require('promise');
const StatefulProcessCommandProxy = require("stateful-process-command-proxy");
const processCommand = 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
const processArgs = ['-NoProfile', '-ExecutionPolicy bypass']
const statefulProcessCommandProxy = new StatefulProcessCommandProxy(
{
name: "powershell",
max: 5,
min: 5,
idleTimeoutMS: 10000,
logFunction: function(severity,origin,msg) {
console.log(' ' + severity.toUpperCase() + " " +origin+" "+ msg);
},
processCommand: processCommand,
processArgs: processArgs,
processRetainMaxCmdHistory : 50,
processInvalidateOnRegex :
{
'any':[{regex:'.*error.*',flags:'ig'}],
'stdout':[{regex:'.*error.*',flags:'ig'}],
'stderr':[{regex:'.*error.*',flags:'ig'}]
},
processCwd : path.join('.', '.'),
processEnvMap : null,
processUid : null,
processGid : null,
initCommands: null,
validateFunction: (processProxy) => {processProxy.isValid()},
preDestroyCommands: null
});
The powershell command which get executed is :
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile "-ExecutionPolicy bypass"
Which return an error (Notice the double quotes on the line above which should not be present).
When modifying the following code within processProxy.js, at line 179 :
this._processOptions['windowsVerbatimArguments'] = true;
Powershell start properly with the following command line :
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy bypass
Could you handle a parameter so that we can (on win32 platform) handle the spawn
parameter windowsVerbatimArguments ?
I can try to do a pull request if you whish.
Regards