gpt4 book ai didi

javascript - 如何从 grunt 任务运行 node_modules 中的脚本?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:32:47 25 4
gpt4 key购买 nike

我想简化如何从命令行运行我们的测试套件。所以我添加了以下 grunt-shell任务到我们的 Gruntfile.js:

module.exports = function( grunt ) {

grunt.initConfig(
{
shell : {
e2e : {
command : "./node_modules/protractor/bin/protractor protractor_conf.js"
}
}
}
);

grunt.loadNpmTasks( "grunt-shell" );

grunt.registerTask( "e2e", ["shell:e2e"] );
};

当我运行任务时,出现错误:

'.' is not recognized as an internal or external command, operable program or batch file.

我找到的所有运行 shell 命令的示例都运行可全局访问的二进制文件,但我想启动本地安装的 Protractor 二进制文件。

我在 Windows 上使用 bash,以防万一。

最佳答案

我正在研究 OSX...但它应该仍然适用于您吗?

我只是在我的 Gruntfile 中提供了一个绝对路径:

module.exports = function(grunt) {

grunt.initConfig({
shell: {
test: {
// command: 'sh /Users/default/Sites/dev/test.sh'
command: 'node /Users/default/Sites/dev/test.js'
}
}
});

grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['shell']);
};

这为我提供了正确的输出。

我遇到的类似问题的一些其他有用任务:

grunt 执行,grunt 运行

关于javascript - 如何从 grunt 任务运行 node_modules 中的脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23706895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com