问题
When using grunt.util.spawn on win32 with spaces in the path of the cmd argument it is calling it without escaping the space. For instance my path contains "C:\Users\Beech Horn" so the error message I receive is
'C:\Users\Beech' is not a recognized as an internal or external command,
operable program or batch file
However grunt.file.exists shows the file is there.
Also if I wrap the cmd argument with '"' + cmd '"', grunt.file.exists can find the file however I get
Fatal error: spawn ENOENT
Has anyone solved this problem already with other grunt plugins?
回答1:
Instead of using the cmd variable directly, first escape spaces in the path:
cmd.replace(' ', '\\ ')
来源:https://stackoverflow.com/questions/20093349/grunt-cmd-with-spaces-in-the-path