-1
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
    });

};

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

grunt 复制 --target=destpath

它说“没有错误地完成”,但没有在目标目录中创建新文件夹。有人可以告诉我代码中的错误是什么吗?

4

1 回答 1

0

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

dest: 'dest/bob.js'
于 2016-02-03T00:30:26.623 回答