930271c3a37bd2cde02c8f011d204442a7506ebb
[yaffs-website] / node_modules / grunt / node_modules / grunt-cli / bin / grunt
1 #!/usr/bin/env node
2
3 'use strict';
4
5 process.title = 'grunt';
6
7 // Especially badass external libs.
8 var findup = require('findup-sync');
9 var resolve = require('resolve').sync;
10
11 // Internal libs.
12 var options = require('../lib/cli').options;
13 var completion = require('../lib/completion');
14 var info = require('../lib/info');
15 var path = require('path');
16
17 var basedir = process.cwd();
18 var gruntpath;
19
20 // Do stuff based on CLI options.
21 if ('completion' in options) {
22   completion.print(options.completion);
23 } else if (options.version) {
24   info.version();
25 } else if (options.gruntfile) { //Note: if both `gruntfile` and `base` are set, use `gruntfile`
26   basedir = path.resolve(path.dirname(options.gruntfile));
27 } else if (options.base) {
28   basedir = path.resolve(options.base);
29 }
30
31 try {
32   gruntpath = resolve('grunt', {basedir: basedir});
33 } catch (ex) {
34   gruntpath = findup('lib/grunt.js');
35   // No grunt install found!
36   if (!gruntpath) {
37     if (options.version) { process.exit(); }
38     if (options.help) { info.help(); }
39     info.fatal('Unable to find local grunt.', 99);
40   }
41 }
42
43 // Everything looks good. Require local grunt and run it.
44 require(gruntpath).cli();