-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwm_prefab_utils.js
More file actions
28 lines (25 loc) · 959 Bytes
/
wm_prefab_utils.js
File metadata and controls
28 lines (25 loc) · 959 Bytes
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
const fs = require('fs');
const util = require('util');
const stat = util.promisify(fs.stat);
const { join } = require('path');
const readDir = util.promisify(fs.readdir);
const getWebAppPath = projectPath => `${projectPath}/src/main/webapp`;
const getPrefabsDirPath = projectPath => `${getWebAppPath(projectPath)}/WEB-INF/prefabs`;
const getPrefabsUsedInApp = async (projectPath) => {
let prefabsUsedInProject = [];
const path = getPrefabsDirPath(projectPath);
return stat(path)
.then(() => {
return new Promise(async (res, rej) => {
for (const dir of await readDir(path)) {
if ((await stat(join(path, dir))).isDirectory()) {
prefabsUsedInProject.push(dir);
}
}
res(prefabsUsedInProject);
});
}, () => Promise.resolve(prefabsUsedInProject))
};
module.exports = {
getPrefabsUsedInApp,
};