运行节点命令x次

Run node command x times

我想 运行 一个节点命令,节点 myfile.js 我想要多少次。 我想从 CLI 发送参数,以便它 运行s 我在参数中提到的次数。 那可以吗?请帮助我。

如果您在 Windows: 你可以制作一个批处理脚本来控制这个动作,它会是这样的:

@echo off 
set /A i=0
:while
if %i% lss %1 (
   SET /A "i = i + 1"
   node "myFile.js"
   goto :while
)

到运行脚本只需在命令行中输入:.\script.bat number

如果您使用的是 Linux: 你可以制作一个shell脚本,它只是语法差异而已。