firstandthird / load-grunt-config

Grunt plugin that lets you break up your Gruntfile config by task
firstandthird.github.io/load-grunt-config/
MIT License
374 stars 64 forks source link

Grunt is not defined #101

Closed felixbillon closed 9 years ago

felixbillon commented 9 years ago

Hi everybody,

I'm trying tu use load-grunt-config, but the plugin not working. Here is my Grunfile.js :

'use strict';

module.exports = function (grunt) {

var path = require('path');

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

var options = {
    configPath: path.join(process.cwd(), 'Grunt')
};

require('load-grunt-config')(grunt, options);

grunt.registerTask('checkCode', ['tslint']);
};

I got a folder named 'Grunt' and a file named tslint.js.

Everytime i use : grunt checkCode in my CLI i got the following error :

Loading "Gruntfile.js" tasks...ERROR ReferenceError: grunt is not defined Warning: Task "checkCode" not found. Use --force to continue.

I also try aliases file but this not work too.

Thanks for your help.

SolomoN-ua commented 9 years ago

Hi, can you provide your tslink.js task config?

felixbillon commented 9 years ago

Hi SolomoN-ua,

You got it ! I solve my problem. Here is my tslink.js :

module.exports = {
    tslint: {
        options: {
             configuration: grunt.file.readJSON("tslint.json")
         },
         files: {
             src: ['**/*.ts']
         }
    }
};

This line don't work : grunt.file.readJSON. So i change my file and that's work perfectly :

module.exports = function (grunt, options) {
   return {
    tslint: {
        options: {
             configuration: grunt.file.readJSON("tslint.json")
         },
         files: {
             src: ['**/*.ts']
         }
      }
 }
  };