jeremyfa / node-exec-sync

IMPORTANT: This repository is no longer maintained.
48 stars 26 forks source link

Error handling needs improvement #14

Closed vesse closed 10 years ago

vesse commented 11 years ago

If the command cannot be executed, execSync will fail when it tries to open the /tmp/id.stdout file which does not exist. For example, var data = execSync("ls unescapedfilename(123).xml", true); will fail:

Error: ENOENT, no such file or directory '/tmp/tmp13516730034130031779543426819146.stdout'
    at Object.fs.openSync (fs.js:338:18)
    at Object.fs.readFileSync (fs.js:182:15)
    at getOutput (node_modules/exec-sync/bin/index.js:39:17)

I would suggest to check for existence of the files if return value of libc.system(cmd); is non-zero, and if the files do not exist, i.e. the command was not executed, report that as an error.

albertmatyi commented 10 years ago

Having same issue when trying to execute: ln "/home/matyas/work/liebherr/expo/dev/.uploads/dot/hSKwhXZNCjR8MsEj8" "/home/matyas/work/liebherr/expo/dev/.uploads/dot/xJvR74MgeCFLrEXuD"

The error: Error: ENOENT, no such file or directory '/tmp/tmp1390554848866407920243467669934.stdout'

The paths are valid and command runs fine if executed manually or via childProcess.spawn

exec-sync@0.1.6

jeremyfa commented 10 years ago

I advice you use this module instead: https://github.com/mgutz/execSync I don't maintain my exec-sync repository anymore as the one above is already providing the same features (and even a bit more).

iwaffles commented 10 years ago

Just a note for those with the same problem: https://github.com/mgutz/execSync seems to solve this issue as mentioned by @jeremyfa