Saturday 3 June 2017

Escape path in node.js cmd

I'm trying to execute system command with node child_process.exec.

Under windows:

foo.exe -p -i "c:\work dir\f$oo.in" -o "c:\work dir\f$oo.out"

Under linux:

foo -p -i 'home/me/work dir/f$oo.in' -o 'home/me/work dir/f$oo.out'

The problem is that paths contain spaces and $ sign - under windows I need to surround it with " under linux wiht '.

Is there some build in function to escape path based on operating system?

Thanks!



via user1038334

No comments:

Post a Comment