Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从外部js文件运行命令并在文件夹-Node.js中列出js文件_Node.js_File_Directory - Fatal编程技术网

如何从外部js文件运行命令并在文件夹-Node.js中列出js文件

如何从外部js文件运行命令并在文件夹-Node.js中列出js文件,node.js,file,directory,Node.js,File,Directory,我有一个名为actions的文件夹,actions包含一些js文件,如run.js、punch.js、lift.js等 当index.js中存在以下情况时,我要做的是列出action文件夹中的所有js文件名:- if(user.act === "help"){ // list all file names in action folder } 我还想在用户执行此命令时在特定文件中运行命令(例如):- if(player.id.play.act === "runB

我有一个名为actions的文件夹,actions包含一些js文件,如run.js、punch.js、lift.js等

当index.js中存在以下情况时,我要做的是列出action文件夹中的所有js文件名:-

if(user.act === "help"){

// list all file names in action folder
}
我还想在用户执行此命令时在特定文件中运行命令(例如):-

if(player.id.play.act === "runButton"){

//Here i want to run everything(commands) in run.js which is in action folder...
}