Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/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
Gruntjs 将参数从命令行传递到grunt复制任务_Gruntjs_Grunt Contrib Copy - Fatal编程技术网

Gruntjs 将参数从命令行传递到grunt复制任务

Gruntjs 将参数从命令行传递到grunt复制任务,gruntjs,grunt-contrib-copy,Gruntjs,Grunt Contrib Copy,我正在尝试从命令行传递复制任务的目标路径。我厌倦了命令 grunt copy--target=destpath 它会显示“无错误完成”,但不会在目标目录中创建新文件夹。有人能告诉我代码中有什么错误吗?尝试将dest更改为合格的js文件路径。像这样: var pathValue=""; module.exports = function(grunt) { grunt.initConfig({ copy: { main: {

我正在尝试从命令行传递复制任务的目标路径。我厌倦了命令

grunt copy--target=destpath


它会显示“无错误完成”,但不会在目标目录中创建新文件夹。有人能告诉我代码中有什么错误吗?

尝试将dest更改为合格的js文件路径。像这样:

var pathValue="";

module.exports = function(grunt) {
    grunt.initConfig({
        copy: {
            main: {
                files: [{
                    cwd: 'srcpath',  // set working folder / root to copy
                    src: '**/*',           // copy all files and subfolders
                    dest: 'pathValue',    // destination folder
                    expand: true
                }]
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.registerTask('copy', function(n) {
        var target = grunt.option('target');
        pathValue = target;
        // do something useful with target here
    });

};

你最终应该能够做到这一点。然而,我将从硬编码开始,以帮助您隔离问题。听起来像是安全问题或路径没有正确指定。首先,我要确保完整的文件路径存在,并且已经有一个可编辑的.js文件可以被覆盖。祝你好运
dest: 'dest/bob.js'