Skip to content
This repository was archived by the owner on Jan 15, 2021. It is now read-only.
This repository was archived by the owner on Jan 15, 2021. It is now read-only.

Referencing an outside variable from a closure in spawn.stderr.on causes jxcore to fail #13

@yaronyg

Description

@yaronyg
function childProcessExecPromise(commandString, currentWorkingDirectory) {
  return new Promise(function (resolve, reject) {
    var commandSplit = commandString.split(' ');
    var command = commandSplit.shift();
    var stdErrData = false;
    var theProcess = spawn(command, commandSplit,
                            { cwd: currentWorkingDirectory});
    theProcess.stdout.on('data', function (data) {
      console.log('' + data);
    });
    theProcess.stderr.on('data', function (data) {
      //stdErrData = true;
      console.log('' + data);
    });
    theProcess.on('close', function (code) {
      if (code !== 0) {
        return reject(code);
      }
      if (stdErrData) {
        return reject(-1);
      }
      return resolve();
    });
  });

If I uncomment stdErrData = true; then JXcore faills.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions