如何修复节点JS中的此命令行调用?

时间:2019-05-03 09:17:30

标签: javascript node.js command-line 7zip

" 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -p**** "C:\tmp\test2.zip" "C:\tmp\"test2.txt"

我正在尝试重构此代码。这将创建test2.zip并压缩test2.txt

必须像

那样重构
"7z" a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -p**** "C:\tmp\test2.zip" "C:\tmp\test2.txt"

在nodeJS中:

var uploadFolder = "C:\tmp\test2.zip";
var fileNmae = "test2.txt";

var command = ' "C:\\Program Files\\7-Zip\\7z.exe" a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -p**** "' + uploadFolder + '" "C:\\tmp\\"' + fileName ;

如何重构此命令,使其看起来像这样:

   "7z" a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -p**** "C:\tmp\test2.zip" "C:\tmp\test2.txt"

1 个答案:

答案 0 :(得分:0)

NPM中可以找到许多7zip的包装。这可能比尝试从NodeJS封装到命令脚本要容易/更好。