get-grunt-target

1.0.2 • Public • Published

Build Status downloads npm Code Climate Test Coverage dependencies

get-grunt-target

Lookup the target for a grunt task

Installation

npm install --save get-grunt-target

Summary

Pass in grunt and the task you're intested in to get back the currently invoked target (if any).

Usage

You can use this library in a Gruntfile (or alternatively, in a task itself) to do dynamic stuff based on the task. If the task you pass in was not invoked in the current build chain, this function returns null. If the task you pass in was invoked once, it returns the string name of the target it was invoked with (which could be undefined if you invoke a multitask without a target name). If the task you pass in was invoked more than once, it returns an array of string targets.

var getTarget = require('get-grunt-target');
 
module.exports = function(grunt) {
  var target = getTarget(grunt, 'test');
};

When grunt test:server is run, target will equal "server".

When grunt test:server test:client is run, target will equal ["server", "client"].

Contributing

I'll be happy to merge any pull request that adds value and has passing tests. Be sure to add a test both for node and for the browser. Tests are run with grunt.

Readme

Keywords

Package Sidebar

Install

npm i get-grunt-target

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

10.2 kB

Total Files

18

Last publish

Collaborators

  • tandrewnichols