forked from ng-bootstrap/ng-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-gen-utils.js
34 lines (28 loc) · 883 Bytes
/
demo-gen-utils.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
var glob = require('glob');
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getDemoComponentNames() {
const path = 'demo/src/app/components/*/';
return glob.sync(path, {})
.map((dir) => {
const dirNoEndingSlash = dir.substr(0, dir.length - 1);
return dirNoEndingSlash.substr(dirNoEndingSlash.lastIndexOf('/') + 1);
})
.sort();
}
function getDemoNames(componentName) {
const base = `demo/src/app/components/${componentName}/demos`;
const path = `${base}/*/`;
return glob.sync(path, {})
.map((dir) => {
const dirNoEndingSlash = dir.substr(0, dir.length - 1);
return dirNoEndingSlash.substr(dirNoEndingSlash.lastIndexOf('/') + 1);
})
.sort();
}
module.exports = {
capitalize: capitalize,
getDemoComponentNames: getDemoComponentNames,
getDemoNames: getDemoNames
};