Skip to content

error.code is not always available #536

@veselov

Description

@veselov

Node version (or tell us if you're using electron or some other framework):

4.x

ShellJS version (the most recent version/Github branch you see the bug on):

0.7.4

Operating system:

Linux FC23

Description of the bug:

Experienced this when running some scripts under mocha:

Example ShellJS command to reproduce the error:

Unknown

Error:

/tmp/shelljs_67e6b2ac42f07ecaa8c5:4

fs.writeFileSync("/tmp/shelljs_2d310a64fef8dfba8311", err ? err.code.toString() : '0');
^

TypeError: Cannot read property 'toString' of undefined
at /tmp/shelljs_67e6b2ac42f07ecaa8c5:4:71
at ChildProcess.exithandler (child_process.js:220:5)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:827:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
exec: internal error
/usr/lib/node_modules/jenkins-mocha/lib/jenkins.js:86
shell.exit(shell.exec(command.join(' ')).code);
^

TypeError: Cannot read property 'code' of null
at module.exports (/usr/lib/node_modules/jenkins-mocha/lib/jenkins.js:86:45)
at Object. (/usr/lib/node_modules/jenkins-mocha/bin/jenkins.js:2:26)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

The crafted shell file (/tmp/shelljs_67e6b2ac42f07ecaa8c5) is not available.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions