Closed colwilson closed 10 years ago
What is grunt.config used for?
They (and many others) use it to access the data backend (your object) like this
grunt.config.get('environment.environments').forEach(function(env) {
You may be interested
https://github.com/logankoester/grunt-environment/pull/2#issuecomment-30716251
On 17 December 2013 00:19, Greg notifications@github.com wrote:
What is grunt.config used for?
— Reply to this email directly or view it on GitHubhttps://github.com/firstandthird/load-grunt-config/pull/22#issuecomment-30715306 .
Col Wilson
Sorry, that's a lot of nonsense "Grunt.initConfighttp://gruntjs.com/api/grunt#grunt.initconfig
There is something wrong, but I seem to have forgotten how I fixed it...
On 17 December 2013 00:19, Greg notifications@github.com wrote:
What is grunt.config used for?
— Reply to this email directly or view it on GitHubhttps://github.com/firstandthird/load-grunt-config/pull/22#issuecomment-30715306 .
Col Wilson
So is everything working as expected?
no.
if you have a package.json of
{
"name": "lgc-example1",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD-2-Clause",
"devDependencies": {
"load-grunt-config": "~0.7.0",
"grunt": "~0.4.2",
"grunt-environment": "~0.3.1"
}
}
and a Gruntfile.coffee of
module.exports = (grunt) ->
require("load-grunt-config") grunt,
config:
thing: "thingy"
number: 42
environment:
default: "development"
environments: ["development", "production"]
version: ->
grunt.file.readJSON("package.json")["version"]
and run
grunt -v
or even
grunt -v environment:development
then it fails because grunt.config is not initialized properly.
Now, I know that it's actually grunt-environment where the code fails, but I think it is asking for something which is quite reasonable, i.e. an initialized grunt.config.
take a look at https://github.com/firstandthird/load-grunt-config/blob/master/lib/load-config.js#L42
I am calling grunt.initConfig(object);
I know, I've raised an issue with grunt-environment which explains what was going on.
https://github.com/logankoester/grunt-environment/issues/3
You can close this now thanks.
On 17 December 2013 16:44, Greg notifications@github.com wrote:
take a look at https://github.com/firstandthird/load-grunt-config/blob/master/lib/load-config.js#L42
I am calling grunt.initConfig(object);
— Reply to this email directly or view it on GitHubhttps://github.com/firstandthird/load-grunt-config/pull/22#issuecomment-30767351 .
Col Wilson
oh. I get it now. I can just move the initConfig to happen before loading the tasks. That will solve it. I'll do that later today
I had real problems using grunt-environment with this module because it complained that grunt.config was null.
This gets around that problem.