-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcise
More file actions
executable file
·67 lines (55 loc) · 1.8 KB
/
concise
File metadata and controls
executable file
·67 lines (55 loc) · 1.8 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
#!/usr/bin/env node
var program = require('commander');
var path = require('path');
var fs = require('fs');
var util = require('../lib/util');
var pkg = require('../package');
program
.usage('[folder]')
.version(pkg.version)
.option('-p, --prod', 'use production version')
.parse(process.argv);
var destinationPath = program.args.shift() || '.';
// Copy templates files
var index = util.loadTemplate('index.html');
var edicon = util.loadTemplate('.editorconfig');
var ignore = util.loadTemplate('.gitignore');
var css = util.loadConcise('css/concise.css')
var cssMin = util.loadConcise('css/concise.min.css')
var js = util.loadConcise('js/concise.js');
var jsMin = util.loadConcise('js/concise.min.js');
// Check if the folder is empty, confirm ovewrite and generate the app
(function generateApp(path) {
util.emptyDirectory(path, function(empty) {
if (empty || program.force) {
createApp(path);
} else {
program.confirm('destination path is not empty, are you sure to continue?', function(ok) {
if (ok) {
process.stdin.destroy();
createApp(path);
} else {
util.abort('Process canceled!')
}
});
}
});
})(destinationPath);
// Create all files to the project
function createApp(path) {
util.mkdir(path, function() {
util.mkdir(path + '/css');
util.mkdir(path + '/images');
util.mkdir(path + '/js');
util.write(path + '/index.html', index);
util.write(path + '/.editorconfig', edicon);
util.write(path + '/.gitignore', ignore);
if (program.prod) {
util.write(path + '/css/concise.css', css)
util.write(path + '/js/concise.js', js);
} else {
util.write(path + '/css/concise.min.css', cssMin)
util.write(path + '/js/concise.min.js', jsMin);
}
});
}