npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@linagora/grunt-run-grunt

v0.1.4

Published

Grunt task to run Gruntfiles in a child process. Gruntception!

Downloads

32

Readme

grunt-run-grunt

This is a fork of grunt-run-grunt Build Status Dependency Status NPM version

Grunt task to run Gruntfiles in a child process. Gruntception!

Console output capture is not reliable on Windows as Node.js there doesn't always flush buffers before exiting. Until this is fixed Windows users should use the Vagrantfile instead (see below). :bangbang:

Getting Started

This plugin requires Grunt >=0.4.0

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 @linagora/grunt-run-grunt --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('@linagora/grunt-run-grunt');

The "run_grunt" task

"Yo dawg! I herd you like grunt, so I put some grunt in your grunt so you can grunt while you grunt." :laughing:

Use the run_grunt task to spawn new processes that run grunt-cli and optionally do work on the result data. It will use the global $ grunt command, just like when you'd run grunt manually.

Main use-case is testing your gruntfile or grunt-plugins, but it is also suited for creative use of gruntfiles and grunt-cli output.

For example use it to verify the final output of various reporters and formatters. Alternately parse the output of the "$grunt --help" command and work with the list of tasks and aliases (without instrumenting the gruntfile in any way).

If you need something similar to run grunt in a production build environment or don't really care about the content of the cli output then you are probably looking for grunt-hub instead. If you need to run tasks from one Gruntfile concurrently use grunt-concurrent or grunt-parallel.

In the future there will also be a way to use this as a standard Node.js module, so you can run grunt from inside standard scripts. Why? Who knows?

Usage

In your project's Gruntfile, add a section named run_grunt to the data object passed into grunt.initConfig().

grunt.initConfig({
	run_grunt: {
		options: {
			minimumFiles: 2
		},
		simple_target: {
			options: {
				log: false,
				process: function(res){
					if (res.fail){
						res.output = 'new content'
						grunt.log.writeln('bork bork');
					}
				}
			},
			src: ['Gruntfile.js', 'other/Gruntfile.js']
		},
	},
})

Options

grunt-cli options

help: boolean,
base: 'string',
'no-color': boolean,
debug: boolean,
stack: boolean,
force: boolean,
tasks: boolean,
npm: 'string',
'no-write': boolean,
verbose: boolean,
version: boolean

Custom options

// pass the tasks to run: either a string or array-of-strings
task: ['clean', 'jshint:strictTarget', 'mocha:subTarget']

// process the result data object
process: function(result){
	// see below for result structure
},

// log child console output
log: true,

// indent child console output with this string
indentLog: '  |  ',

// save raw output to file
logFile: null,

// modify env variables
env: {},

// apply an output parser (see below for values)
parser: '',

// how many parallel grunts to run
concurrent: <number> cpu-cores,

// expect at least this many files
minimumFiles: 1,

// change the cwd of the gruntfile
cwd: null,

//--- experimental options

// generate cli command
debugCli: false,

// save .bat and shellscripts
writeShell: null,

// don't fail
expectFail: false

// pass args to append to the command line
args: {}

Process result object

// status, can override
fail: false,
output: 'string',

// parsed data
parsed: {
	'parseHelp' : {}
	..
},

// raw grunt.util.spawn callback arguments
error,
res,
code,

// used parameters
src: 'path/to/Gruntfile.js',
cwd: 'string',
tasks: [],
options: {},

//cleaned src
gruntfile: 'Gruntfile',

// timing
start: Date.now(),
end: 0,
duration: 0

Parsers

parseHelp

Parse grunt -h output

  • Use the process option to access the data.
  • Returns result.parsed.parseHelp object with task and alias names.
  • Requires help option (in a later version this will be forced)

History

  • 0.1.2 - Added env option
  • 0.1.1 - Changed error behaviour.
  • 0.0.4 - NPM push.
  • 0.0.3 - Various construction work.
  • 0.0.2 - Solidifying and added parsing helper to extract tasks and aliases.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Vagrant

There is a Vagrantfile and set of Chef cookbooks to use with Vagrant for easy testing on a Linux VM. It will install a node.js from package, install the dependencies and enable grunt.

License

Copyright (c) 2013 Bart van der Schoor

Licensed under the MIT license.

Bitdeli Badge