在Windows调用exec / spawn之前normalize命令?
假设我正试图从当前目录调用ffmpeg。 在linux上,我会调用exec
或者spawn
'./ffmpeg'
。 为了让这个代码可以移植到Windows,我需要去除'./'
还是以某种方式照顾我?
这只是答案的一半:欢迎任何人修改并扩展它。
这里是我在源代码中挖掘的结果:
exec
方法对平台进行一个小的检查(从源头获取):
if (process.platform === 'win32') { file = 'cmd.exe'; args = ['/s', '/c', '"' + command + '"']; options = util._extend({}, options); options.windowsVerbatimArguments = true; } else { file = '/bin/sh'; args = ['-c', command]; }
我不知道你是如何将ffmpeg
添加到Windows上的PATH的,所以这取决于你的设置。 在任何情况下,只需传递给exec
命令,就好像你将从cmd.exe
shell运行一样。
然而我无法find类似的spawn
。