Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Latest commit

 

History

History
255 lines (162 loc) · 6.04 KB

GruntHorde.md

File metadata and controls

255 lines (162 loc) · 6.04 KB

Packageable, composable grunt configuration modules

Source: lib/grunt-horde/index.js

exports.GruntHorde()

Reference to GruntHorde.

Go: TOC | exports

exports.create(grunt)

Create a new GruntHorde.

Parameters:

  • {object} grunt Instance injected into Gruntfile.js

Return:

{object}

Go: TOC | exports

exports.extend(ext)

Extend GruntHorde.prototype.

Parameters:

  • {object} ext

Return:

{object} Merge result.

Go: TOC | exports

GruntHorde()

GruntHorde constructor.

Usage:

// Gruntfile.js
module.exports = function(grunt) {
  require('grunt-horde')
    .create(grunt)
    .loot('my-base-config-module')
    .loot('./config/grunt')
    .attack();
};

Properties:

  • {object} config Gruntfile.js values indexed by grunt method name
    • {object} initConfig
    • {object} loadNpmTasks
    • {object} loadTasks
    • {object} registerMultiTask
    • {object} registerTask
  • {object} frozenConfig Track config keys set in Gruntfile.js
    • Allow client project to override defaults set in modules.
    • Keys: config key names, values: not used
  • {string} [home=process.cwd] Absolute path to project root dir w/out trailing slash
  • {object} grunt Instance injected into Gruntfile.js
  • {array} lootBatch Pending merge functions collected in Gruntfile.prototype.loot

Go: TOC

GruntHorde.prototype.attack()

Apply configuration.

Run all supported grunt configuration methods.

Go: TOC | GruntHorde.prototype

GruntHorde.prototype.home(cwd)

Set working directory used to resolve relative paths.

Parameters:

  • {string} cwd

Return:

{object} this

Go: TOC | GruntHorde.prototype

GruntHorde.prototype.kill(key)

Remove a configuration property. Supports x.y.z property paths.

Usage:

horde.demand('initConfig.x', 20);
horde.kill('initConfig.x');
console.log(grunt.config.getRaw().x); // undefined
console.log(horde.learn('initConfig.x')); // undefined

Emits:

  • grunt-horde:kill on every invocation.

Parameters:

  • {string} key <section>.<key>
    • Ex. initConfig.x.y.z, registerTask.default, etc.
    • Sections: initConfig, loadNpmTasks, loadTasks, registerTask, registerMultiTask

Return:

{object} this

See:

Go: TOC | GruntHorde.prototype

GruntHorde.prototype.learn(key)

Get a configuration property. Supports x.y.z property paths.

Usage:

horde.demand('initConfig.x.y.z', 20);
horde.learn('initConfig.x.y.z'); // 20

Parameters:

  • {string} key <section>.<key>
    • Ex. initConfig.x.y.z, registerTask.default, etc.
    • Sections: initConfig, loadNpmTasks, loadTasks, registerTask, registerMultiTask

Return:

{mixed}

Go: TOC | GruntHorde.prototype

GruntHorde.prototype.loot(name)

Load a config module. Merge in its payload.

  • Merge operation is deferred until GruntHorde.prototype.attack.
  • Payloads are merged recursively, last wins.
  • Loads tasks/, if present, with grunt.loadTasks.

Supported module types:

  • Name of locally installed NPM package
  • Relative path, ex. ./config/grunt/
  • Absolute path

Usage:

horde.home('/proj/home');
horde.loot('base'); // require('/proj/home/node_modules/base');
horde.loot('./base'); // require('/proj/home/base.js');
horde.loot('/path/to/base'); // require('/path/to/base');

Example layout:

initConfig/
  index.js
  eslint.js
  uglify.js
  shell.js
tasks/
  precommit.js
loadTasks.js
loadNpmTasks.js
registerTask.js
registerMultiTask.js

Parameters:

  • {string} name Module path, see Usage above for examples

Return:

{object} this

See:

Go: TOC | GruntHorde.prototype

GruntHorde.prototype.demand(key, val)

Set a configuration property. Supports x.y.z property paths.

Usage:

horde.demand('x.y.z', 20);
console.log(horde.learn('x.y.z')); // 20
console.log(grunt.config.getRaw().x.y.z); // 20

Emits:

  • grunt-horde:demand on every invocation.

Parameters:

  • {string} key <section>.<key>

    • Ex. initConfig.x.y.z, registerTask.default, etc.
    • Sections: initConfig, loadNpmTasks, loadTasks, registerTask, registerMultiTask
  • {mixed} val

Return:

{object} this

See:

Go: TOC | GruntHorde.prototype

—generated by apidox