jeremyfa / node-exec-sync

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

cat and > command not work!! #15

Closed xiaojue closed 7 years ago

xiaojue commented 11 years ago

run execSync("cat 1.js 2.js > 3.js"); command

3.js is empty ? why?

or run like this command:

execSync('java -jar ' + this.jsTool + ' --js=' + jsfile + ' --js_output_file=' + target);

the target file is empty too。

but like these command:

exec("cat 1.js 2.js > 3.js");
exec('java -jar ' + this.jsTool + ' --js=' + jsfile + ' --js_output_file=' + target);

it will be right....

caspian311 commented 11 years ago

It's because all commands are wrapped in this: cmd = "#{cmd} > #{dir}/#{stdout} 2> #{dir}/#{stderr}"

Which sucks for any sort of command that actually chains together outputs. Best I've been able to do to get around it, is to make your command end with an additional empty echo. Something like this... execSync('lessc site.less > site.css ; echo ""');

If anyone has something better, I'd love to hear it.

jeremyfa commented 7 years ago

Quoting the repository README:

IMPORTANT: This repository is no longer maintained.

The same feature is now built-in with node v0.12: >https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options