🚀 DAY 4 OF LAUNCH WEEK: Introducing GitHub Actions Scanning Support.Learn more →
Socket
Book a DemoInstallSign in
Socket

grunt-generate-configs

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-generate-configs

CLI to generate separate grunt configuration files automatically

Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

grunt-generate-configs GitHub versionBuild Status

CLI to generate separate grunt configuration files automatically

This command will take your big, fat grunt configuration object and automatically generate separate files to store the task configuration objects in. It's a one time operation to be done before you start using load-grunt-configs

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-generate-configs

(There's no need for the --save flags, since this task should be run only once.)

Once the plugin has been installed, you can run it from the command line:

generate_configs

The command will parse your grunt configuration object and automatically create files for each task.

Now you can safely remove the module if you want:

npm uninstall grunt-generate-configs

Command line options

  • --target=<dir> you can specify the output directory using the target-flag. E.g.: grunt generate_configs --target=foo will create a foo directory instead of config.
  • --type=[js|json|coffee|yaml] allows you to output the configuration objects as json, yaml, coffee files or javascript modules.

Examples

For example, if this is your grunt configuration inside Gruntfile.js:

grunt.initConfig({
    jshint   : {
        all     : [
            'Gruntfile.js', 'tasks/*.js', '<%=nodeunit.tests%>'
        ],
        options : {
            jshintrc : '.jshintrc',
        },
    },

    // Before generating any new files, remove any previously-created files.
    clean    : {
        config : ['config'],
    },

    // Unit tests.
    nodeunit : {
        tests : ['tests/*_test.js'],
    },
});

It will create the files jshint.json, clean.json and nodeunit.json inside a config directory, containing the configuration objects:

//file: config/jshint.json
{
  "all": [
    "Gruntfile.js",
    "tasks/*.js",
    "<%=nodeunit.tests%>"
  ],
  "options": {
    "jshintrc": ".jshintrc"
  }
}
//file: config/clean.json
{
  "config": [
    "config"
  ]
}
//file: config/nodeunit.json
{
  "tests": [
    "tests/*_test.js"
  ]
}

Once these files are generated, use the load-grunt-configs module to automatically load all configuration files:

npm install load-grunt-configs --save-dev

and inside your Gruntfile.js replace the grunt configuration object with:

var configs = require('load-grunt-configs')(grunt);
grunt.initConfig(configs);

See the project for more information, options and examples: load-grunt-configs

Example output

Changelog

v0.4.0

  • adds cli

v0.3.0

  • Adds demos
  • Adds yaml support
  • Adds Coffeescript support

v0.2.0

  • Test all possibilities, idiot!
  • fixes #2, incorrect ext for js files

v0.1.2

  • Fixes #1, moved inquirer from devDeps to deps

v0.1.1

  • keywords, keywords, keywords, sigh

v0.1.0

  • Fixes CLI options examples
  • creates task grunt-generate-configs

License

Copyright (c) 2014 Camille Reynders Licensed under the MIT license.

Analytics

Keywords

grunt

FAQs

Package last updated on 22 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts