Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

exiguus/js.node.grunt.config.helper

Repository files navigation

tests coverage maintainability

js.node.grunt.config.helper

Node.js Grunt Config Helper Class to Help with Grunt configs and tasks.

npm

npm

npm install --save-dev js.node.grunt.config.helper

Example

Extend Grunt Config Jit Environment

Using the Extend functionality in a jit-grunt Environment like:

Project/
      |build/
      |    |helper/
      |            |_grunt/
      |                  |task_name/
      |                  |        |tasks1.js
      |                  |        |tasks2.js
      |                  |task_name.js
      |Gruntfile.js

Extend task_name.js with task1.js and task2.js from task_name/ directory. task_name.js filename must be the task name of the Grunt Plugin.

// task_name.js
module.exports = function() {
  const path = require('path');
  const GruntConfigHelper = require('js.node.grunt.config.helper');
  const requireDirectory = path.resolve(__dirname, 'task_name');
  const extendConfigHelper = new GruntConfigHelper(requireDirectory);
  const tasks = extendConfigHelper.getTasks();
};

Extend Grunt Config in standard Gruntfile.js Environment

Using the Extend functionality in a standard Grunt Environment:

Project/
      |build/
      |    |helper/
      |            |_grunt/
      |                  |task1.js
      |                  |task2.js
      |Gruntfile.js

Extend Gruntfile.js with task1.js and task2.js by filename. task1.js and task2.js filename must be the task name of the Grunt Plugin.

// Gruntfile.js
module.exports = function (grunt) {

  const path = require('path');
  const GruntConfigHelper = require('js.node.grunt.config.helper');
  const requireDirectory = path.resolve(__dirname, 'build/helper/_grunt');
  const extendConfigHelper = new GruntConfigHelper(requireDirectory, true);
  const tasks = extendConfigHelper.getTasks();
  // Project configuration.
  grunt.initConfig({
    tasks, // {task1: {...}, task2: {...}}
    ...
  })
  ...

Documentation

jsDoc