-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
47 lines (38 loc) · 1.67 KB
/
init.js
File metadata and controls
47 lines (38 loc) · 1.67 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
'use strict';
exports.name = 'init';
exports.usage = '[options] <path>'
exports.desc = 'auto create your project';
exports.register = function(commander){
commander
.option('-n, --name [name]', 'project name', String, '')
.option('-m, --modulename [name]', 'project modulename', String, '')
.option('-c, --charset [value]', 'project charset', String, 'utf-8')
.action(function(){
var args = Array.prototype.slice.call(arguments);
var path = args.shift();
if(typeof path != 'string'){
feather.log.error('invalid path');
return;
}
var _path = process.cwd() + '/' + path + '/';
if(feather.util.exists(_path)){
feather.log.error(path + ' is exists!');
return;
}
feather.util.mkdir(_path);
var options = arguments[arguments.length - 1];
var conf = feather.util.read(__dirname + '/vendor/feather_conf.js');
['name', 'modulename', 'charset'].forEach(function(name){
conf = conf.replace('${' + name + '}', options[name]);
});
conf = conf.replace('${cliname}', feather.cli.name);
feather.util.write(_path + feather.cli.name + '_conf.js', conf);
feather.util.mkdir(_path + 'page/' + options.modulename);
feather.util.write(_path + 'page/index.' + feather.config.get('template.suffix'), 'welcome to ' + feather.cli.name);
feather.util.mkdir(_path + 'test');
feather.util.mkdir(_path + 'static/' + options.modulename);
feather.util.mkdir(_path + 'static/' + options.modulename);
feather.util.mkdir(_path + 'static/' + options.modulename);
feather.util.mkdir(_path + 'component/' + options.modulename);
});
};