Created
December 6, 2013 16:34
-
-
Save robbschiller/7827828 to your computer and use it in GitHub Desktop.
Node User Group Meetup on Grunt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Contents for the 1/15/14 Orlando Node User Group Meetup | |
Topic: Grunt.js |
Grunt-Cli Code
- Grunt Cli just finds the grunt module relative to where you are
- Not locked into a specific version of grunt
#!/usr/bin/env node
'use strict';
process.title = 'grunt';
// Especially badass external libs.
var findup = require('findup-sync');
var resolve = require('resolve').sync;
// Internal libs.
var options = require('../lib/cli').options;
var completion = require('../lib/completion');
var info = require('../lib/info');
var path = require('path');
var basedir = process.cwd();
var gruntpath;
// Do stuff based on CLI options.
if ('completion' in options) {
completion.print(options.completion);
} else if (options.version) {
info.version();
} else if (options.gruntfile) {
basedir = path.resolve(path.dirname(options.gruntfile));
}
try {
gruntpath = resolve('grunt', {basedir: basedir});
} catch (ex) {
gruntpath = findup('lib/grunt.js');
// No grunt install found!
if (!gruntpath) {
if (options.version) { process.exit(); }
if (options.help) { info.help(); }
info.fatal('Unable to find local grunt.', 99);
}
}
// Everything looks good. Require local grunt and run it.
require(gruntpath).cli();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basics
module.exports = function(grunt) {};
grunt.loadNpmTasks()
grunt.initConfig()