-
Notifications
You must be signed in to change notification settings - Fork 0
/
bby.js
executable file
·121 lines (95 loc) · 3.2 KB
/
bby.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env node
var grunt = require("grunt");
var task = process.argv[2];
var bbyHome = process.mainModule.filename.replace("bby.js","");
var baseGruntfile = grunt.file.findup('Gruntfile.js',{cwd: bbyHome, nocase: true});
//Set base path to load included tasks and then return the base path to the current working directory.
grunt.file.setBase(bbyHome);
grunt.option("bby-home", bbyHome);
var tasks = [
// Load grunt-jasmine-task used for testing Jasmine.
"grunt-contrib-jasmine",
// Load grunt-targethtml to allow seamless targeted builds.
"grunt-targethtml",
// Load grunt-contrib tasks.
"grunt-contrib-clean",
"grunt-contrib-copy",
"grunt-contrib-less",
"grunt-contrib-cssmin",
"grunt-contrib-stylus",
"grunt-contrib-jshint",
"grunt-contrib-requirejs",
"grunt-contrib-concat",
"grunt-contrib-handlebars",
"grunt-contrib-uglify",
//non cotribs swap out if a contrib does it as it'll probably be better maintained.
"grunt-cssjoin",
//init scaffolding task!
"grunt-init"
// Load the remaining tasks (init/server/requirejs) from bbb.
];
for(var task in tasks){
grunt.task.loadNpmTasks(tasks[task]);
}
grunt.loadTasks("tasks");
grunt.file.setBase(process.env.PWD);
//console.log(grunt.file.findup('Gruntfile.js', {nocase: true}));
//console.log(grunt.file.findup('Gruntfile.js',{cwd: bbyHome, nocase: true}));
//console.log(process.cwd());
// Load in required grunt tasks.
//grunt.loadTasks("tasks");
// Draw the help screen.
function displayHelp() {
var pkg = require("./package.json");
grunt.log.writeln();
grunt.log.writeln(pkg.description);
grunt.log.writeln((" " + pkg.name + " ").green.inverse
+ " Version - " + pkg.version);
// Borrowed heavily from the Grunt help source.
var col1len = 0;
var opts = Object.keys(grunt.cli.optlist).map(function(long) {
var o = grunt.cli.optlist[long];
var col1 = '--' + (o.negate ? 'no-' : '') + long + (o.short ? ', -' + o.short : '');
col1len = Math.max(col1len, col1.length);
return [col1, o.info];
});
var widths = [1, col1len, 2, 76 - col1len];
var tasksList = Object.keys(grunt.task._tasks).sort();
if (tasksList.length) {
displayTasks("Backbone Boilerplate ", tasksList);
}
function displayTasks(name, tasksList) {
var tasks = tasksList.map(function(name) {
col1len = Math.max(col1len, name.length);
var info = grunt.task._tasks[name].info;
// Ensure the message ends with a `.`.
if (info[info.length-1] !== ".") {
info += ".";
}
return [name, info.grey];
});
grunt.log.writeln();
grunt.log.writeln(("Usage: bby <task_name>").yellow);
grunt.log.writeln();
tasks.forEach(function(a) {
grunt.log.writetableln(widths,
['', grunt.util._.pad(a[0], col1len), '', a[1]]
);
});
}
grunt.log.writeln();
}
// Immediately display help screen if no arguments.
if (process.argv.length === 2) {
// Initialize task system so that the tasks can be listed.
grunt.task.init([], {help: true});
// Do not proceed further.
return displayHelp();
}
// If a Jam specific task is found, defer to the Jam task.
// Otherwise, invoke the CLI.
if(grunt.file.findup('Gruntfile.js', {nocase: true})){
grunt.cli();
}else{
grunt.cli({gruntfile:baseGruntfile, base:process.env.PWD});
}