-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake.js
More file actions
132 lines (98 loc) · 3.4 KB
/
make.js
File metadata and controls
132 lines (98 loc) · 3.4 KB
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
122
123
124
125
126
127
128
129
130
131
132
/**
* @overview Build file
* @author Vitor Britto
*/
'use strict';
// =============================================================================
// CONFIGURATION
// =============================================================================
require('shelljs/make');
require('colors');
var system = require('os').platform,
isLinux = (system === 'linux'),
isMac = (system === 'darwin');
var config = {
src_view: './app/',
src_style: './app/styles/',
src_script: './app/scripts/',
src_spec: './app/spec/',
dist_view: './public/',
dist_style: './public/styles/',
dist_script: './public/scripts/'
};
// =============================================================================
// TASKS
// =============================================================================
target.all = function() {
target.executable();
target.build();
target.npm();
target.info();
// Lastly, avoiding to interrupt the process
rm('-rf', ['make.js']);
echo('✔ All done'.green);
};
target.npm = function() {
if (!which('csslint')) {
echo('→ Installing CSSLint...'.yellow);
exec('npm i csslint -gq');
echo('✔ Packages installed successfully.'.green);
}
if (!which('stylus')) {
echo('→ Installing Stylus...'.yellow);
exec('npm i stylus -gq');
echo('✔ Packages installed successfully.'.green);
}
if (!which('jshint')) {
echo('→ Installing JSHint...'.yellow);
exec('npm i jshint -gq');
echo('✔ Packages installed successfully.'.green);
}
if (!which('browserify')) {
echo('→ Installing Browserify...'.yellow);
exec('npm i browserify -gq');
echo('✔ Packages installed successfully.'.green);
}
if (!which('uglifyjs')) {
echo('→ Installing UglifyJS...'.yellow);
exec('npm i uglify-js -gq');
echo('✔ Packages installed successfully.'.green);
}
if (!which('mocha')) {
echo('→ Installing Mocha...'.yellow);
exec('npm i mocha -gq');
echo('✔ Packages installed successfully.'.green);
}
};
target.executable = function() {
if (isMac || isLinux) {
exec('chmod u+x ./just.js');
echo('✔ Script is now executable'.cyan);
}
};
target.build = function() {
// Create Structure
echo('→ Creating structure'.yellow);
mkdir('-p', [config.src_style, config.src_script, config.src_spec, config.dist_style, config.dist_script]);
// Copy template files
echo('→ Copying files'.yellow);
cp('-rf', './lib/template/style.styl', config.src_style);
cp('-rf', './lib/template/app.js', config.src_script);
cp('-rf', './lib/template/index.js', config.src_spec);
cp('-rf', './lib/template/index.html', config.dist_view);
cp('-rf', './lib/template/.*rc', './');
// Remove stuff you don't want
echo('→ Removing unecessary files'.yellow);
rm('-rf', ['./.git', './lib/template']);
// Install dependencies
echo('→ Checking for dependencies'.yellow);
exec('npm i chai --save-dev -q');
};
target.info = function() {
echo('');
echo('-----------------------------------------------------------');
echo('→ Aplication source files at: '.cyan + config.src_view);
echo('→ Public files at: '.cyan + config.dist_view);
echo('-----------------------------------------------------------');
echo('');
};