Grunt cmd with spaces in the path

泪湿孤枕 提交于 2020-02-25 08:36:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!