Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.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
Javascript 为什么grunt banner options.process()会向我的横幅添加多个文件名?_Javascript_Node.js_Gruntjs - Fatal编程技术网

Javascript 为什么grunt banner options.process()会向我的横幅添加多个文件名?

Javascript 为什么grunt banner options.process()会向我的横幅添加多个文件名?,javascript,node.js,gruntjs,Javascript,Node.js,Gruntjs,我正在学习/将grunt设置到我的项目工作流中,我一直在试图弄清楚为什么grunt横幅选项。process()devDependency会将后续文件名添加到项目文件中,请参见下文 有关grunt横幅的my GrunFile.js任务片段: // Banner inserted at top of the generated files, such a minified CSS banner: '/**\n' + ' * <%= pkg.nam

我正在学习/将grunt设置到我的项目工作流中,我一直在试图弄清楚为什么grunt横幅选项。process()devDependency会将后续文件名添加到项目文件中,请参见下文

有关grunt横幅的my GrunFile.js任务片段:

        // Banner inserted at top of the generated files, such a minified CSS
    banner: '/**\n' +
            ' * <%= pkg.name %> - Version <%= pkg.version %>\n' +
            ' * <%= pkg.description %>\n' +
            ' * Author: <%= pkg.author.name %> - <%= pkg.author.email %>\n' +
            ' * Build date: <%= grunt.template.today("yyyy-mm-dd HH:MM:ss") %>\n' +
            ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.company %>\n' +
            ' * Released under the <%= pkg.license %> license\n' +
            ' */\n',

    usebanner: {
        dist: {
            options: {
                position: 'top',
                banner: '<%= banner %>',
                linebreak: true,
                process: function( filepath ) {
                    var ndx = 4;
                    var file = " * File: <%= filename %>\n *";
                    var banner = this.banner;
                    banner = [banner.slice(0, ndx), file, banner.slice(ndx)].join('');

                    return grunt.template.process(
                        banner,
                        { data: {
                            filename: filepath.match(/\/([^/]*)$/)[1]
                        } } );
                }
            },
            files: {
                    src: [ './build/**/*.js', './build/**/*.css' ]
            }
        }
    },
但是,在后续文件中,文件名开始堆叠:

/**
 * File: master.css
 * * File: script.js
 *
 * Project - Version 0.1.0
 * Grunt deployed project.
 * Author: Someone - some@one.com
 * Build date: 2014-06-18 17:33:10
 * Copyright (c) 2014 Company
 * Released under the MIT license
 */

@media -sass-debug-info{filename{font-family:file\:\/\/D\:\/htdocs\/project\/dev\/scss\/master\.scss}line{font-family:\0000320}}
html {
  background: #f4f4f4;
}
/**
 * File: master.css
 * * File: script.js
 *
 * Project - Version 0.1.0
 * Grunt deployed project.
 * Author: Someone - some@one.com
 * Build date: 2014-06-18 17:33:10
 * Copyright (c) 2014 Company
 * Released under the MIT license
 */

@media -sass-debug-info{filename{font-family:file\:\/\/D\:\/htdocs\/project\/dev\/scss\/master\.scss}line{font-family:\0000320}}
html {
  background: #f4f4f4;
}