How to config.get () a project variable in an initConfig task in Grunt?

In Grunt, I have custom multitasking that extracts paths from an HTML file and uses grunt.config.set()to add the found paths to an array in config called "pathsfound".

I want to use grunt.config.get()to access these paths so that I can use them for concat, uglify, etc.

Gruntfile.coffee

    pathfinder:
        dist:
            files: [
                expand: true
                cwd:  '<%= yeoman.app %>'
                src: '*.html'
            ]
    concat:
        dist:
            src: grunt.config.get('pathsfound')
            dest: 'stuff.js'

And my registered task looks like this:

grunt.registerTask 'dist', ['pathfinder:dist', 'concat:dist']

However, the concat task gives me an error TypeError: Cannot call method 'indexOf' of undefined, assuming that grunt.config.get()it cannot find the variable pathsfoundin initConfig.

Is there any way to lazy load configuration variables during the initConfig phase?

+4
1

, grunt.config.get , , .

- :

concat:
  dist:
    src: "<%= pathsfound.bower %>"

. , , , .

+5

All Articles