-
Notifications
You must be signed in to change notification settings - Fork 9
/
util.js
118 lines (105 loc) · 3.05 KB
/
util.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
(function() {
'use strict';
/**
* cssTypeData configuration
* @type {cssTypeData}
*/
var cssTypeData = {
'less': {
plugin: 'gulp-less',
pluginVersion: '^3.0.5',
pipeCommand: 'g.less()',
extension: 'less'
},
'sass': {
plugin: 'gulp-sass',
pluginVersion: '^2.2.0',
pipeCommand: 'g.sass()',
extension: 'scss'
},
'styl': {
plugin: 'gulp-stylus',
pluginVersion: '^2.3.1',
pipeCommand: 'g.stylus({use: [require(\'nib\')()]})',
extension: 'styl',
extraDependencies: {
'nib': '^1.1.0'
}
}
};
/**
* Proposes the names based on the path/package.json file.
* @return {String} name
*/
function getNameProposal() {
var path = require('path');
try {
return require(path.join(process.cwd(), 'package.json')).name;
} catch (e) {
return path.basename(process.cwd());
}
};
/**
* Organize quize.
* @return {String} name
*/
function getDefaultOption(args, index) {
if (args && args[index]) {
return args[index];
} else {
return null;
}
};
var runtimeMode = 'LIVE'; //Other option is 'TEST'
function setRuntimeMode(mode) {
runtimeMode = mode;
};
function getRuntimeMode() {
return runtimeMode;
};
/**
* Get Modules proposal
* @return {list} dir
*/
function getModuleProposal(appDir) {
if (getRuntimeMode() === 'TEST') {
return ['module1', 'module2'];
}
var modules = [];
var componentsDir = appDir;// + '/components';
var fs = require('fs');
var finalList = [];
if (fs.existsSync(componentsDir)) {
modules = fs.readdirSync(componentsDir);
for (var i = 0; i < modules.length; i++) {
var stats = fs.statSync(componentsDir + '/' + modules[i]);
if (stats.isDirectory()) {
finalList.push(modules[i]);
}
}
}
return finalList;
};
/**
* Get global Options
* command line options
* --appdir Default Application location
* --base is the base for the application
* Note: if both are padssed then it will search on base + appdir
* @return {Object} name
*/
function getGlobalOptions() {
var argv = require('yargs').argv;
return {
appDir: argv.appdir || 'src/app',
base: argv.base || './'
};
};
module.exports.cssTypeData = cssTypeData;
module.exports.getNameProposal = getNameProposal;
module.exports.getDefaultOption = getDefaultOption;
module.exports.setRuntimeMode = setRuntimeMode;
module.exports.getRuntimeMode = getRuntimeMode;
module.exports.getModuleProposal = getModuleProposal;
module.exports.getGlobalOptions = getGlobalOptions;
})();