coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.79k stars 358 forks source link

XML always Generated for stopparentfirst with value undefined #209

Open AshishShanker opened 6 years ago

AshishShanker commented 6 years ago

I noticed that even if I don't specify the stopparentfirst parameter when initializing the Service object, I always get the stopparentfirst argument and a value of undefined, instead of the default of false-y.

For example, the following code:

const svc = new Service(
    {
        name: 'SomeName"
        description: 'SomeDescription',
        script:'somefile.js',
    }
);
svc.install();

Will always have the following in the generated somefile.xml

    <argument>--stopparentfirst</argument>
    <argument>undefined</argument>

Looking at code we should probably use the approach we use for --abortonerror:

    _xml: {
      enumerable: false,
      get: function(){
        var wrapperArgs = [
          '--file', this.script,
          '--log', this.name + ' ' + 'wrapper',
          '--grow', this.grow,
          '--wait', this.wait,
          '--maxrestarts', this.maxRestarts,
          '--abortonerror', (this.abortOnError==true?'y':'n'),
          '--stopparentfirst', (this.stopparentfirst==true?'y':'n') // changed line
        ];