How to pass in package.json array to grunt.js

后端 未结 3 1885
深忆病人
深忆病人 2021-01-11 12:53

is there a way to pass in an array to grunt.js from the package.json file? I\'ve tried a few different ways and none of them seem to work. I currently have:

         


        
相关标签:
3条回答
  • 2021-01-11 12:54

    Since gruntjs in run in node you can access the package.json like:

    var package = require('./package.json'),
        property = package.property[0];
    
    0 讨论(0)
  • 2021-01-11 12:57
    grunt.initConfig({
      lint: grunt.file.readJSON('package.json').lint,
    });
    
    0 讨论(0)
  • 2021-01-11 13:19

    I think that the <%= … %> syntax (variable interpolation in Underscore's template system) can only output strings, not arrays/objects.

    Try this instead:

    lint: {
        files: '<config:pkg.lint>'
    }
    

    I found this syntax in Grunt's jQuery init task.

    0 讨论(0)
提交回复
热议问题