How to config.get() a project variable into a task's initConfig in Grunt?

Viewed 2468

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

I want to use grunt.config.get() to access those paths so that I can use them to 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:

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

However, the concat task is giving me an TypeError: Cannot call method 'indexOf' of undefined error, suggesting that grunt.config.get() can't find the pathsfound variable in initConfig.

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

1 Answers
Related