-
Notifications
You must be signed in to change notification settings - Fork 95
/
patternlab.js
86 lines (71 loc) · 1.85 KB
/
patternlab.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
// NOTE: named arguments passed to npm scripts must be prefixed with '--'
// e.g. npm run loadstarterkit -- --kit=some-kit-name --clean
const plConfig = require('./patternlab-config.json');
const patternlab = require('patternlab-node')(plConfig);
function getConfiguredCleanOption() {
return plConfig.cleanPublic;
}
function build(done) {
done = done || function(){};
const buildResult = patternlab.build(() => {}, getConfiguredCleanOption());
// handle async version of Pattern Lab
if (buildResult instanceof Promise) {
return buildResult.then(done);
}
return null;
}
function version() {
patternlab.version();
}
function help(){
patternlab.help();
}
function patternsonly() {
function noop(){}
patternlab.patternsonly(noop, plConfig.cleanPublic);
}
function liststarterkits() {
patternlab.liststarterkits()
}
function loadstarterkit(kit, clean) {
if(!clean) {
clean = false;
}
patternlab.loadstarterkit(kit, clean);
}
function installplugin(plugin) {
patternlab.installplugin(plugin);
}
for (var i=0; i < process.argv.length; i++) {
switch (process.argv[i]) {
case 'build':
build();
break;
case 'version':
version();
break;
case 'help':
help();
break;
case 'patternsonly':
patternsonly();
break;
case 'liststarterkits':
liststarterkits();
break;
case 'loadstarterkit':
if(process.env.npm_config_kit) {
loadstarterkit(process.env.npm_config_kit, process.env.npm_config_clean);
} else {
console.info("====[ Pattern Lab Error: No Valid Kit Found ]====");
}
break;
case 'installplugin':
if(process.env.npm_config_plugin) {
installplugin(process.env.npm_config_plugin);
} else {
console.info("====[ Pattern Lab Error: No Valid Plugin Found ]====");
}
break;
}
}