-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwm_utils.js
More file actions
47 lines (44 loc) · 1.32 KB
/
wm_utils.js
File metadata and controls
47 lines (44 loc) · 1.32 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
const node_path = require("path");
const getWmNgAppName = ()=> 'wm-gen-ng-proj';
const getGeneratedApp = path => node_path.resolve(`${path}/${getWmNgAppName()}`);
// const getSspaPath = path => node_path.resolve(`${path}/wm-ng-app`);
const getSspaPath = path => getGeneratedApp(path);
const getBundlePath = path => node_path.resolve(`${path}/wm-sspa-dist`);
const getPOMPath = path => node_path.resolve(`${path}/pom.xml`);
const { exec } = require("child_process");
function execCommand(command, options = {}) {
console.log(`Running the Command - ${command}`);
return new Promise((resolve, reject) => {
const child = exec(command, options);
// Stream stdout
if (child.stdout) {
child.stdout.on("data", (data) => {
process.stdout.write(data);
});
}
// Stream stderr
if (child.stderr) {
child.stderr.on("data", (data) => {
process.stderr.write(data);
});
}
// Handle exit
child.on("close", (code) => {
if (code === 0) {
resolve(); // You can also resolve with { stdout, stderr } if needed
} else {
reject(new Error(`Command failed with code ${code}`));
}
});
child.on("error", (err) => {
reject(err);
});
});
}
module.exports = {
getGeneratedApp,
getBundlePath,
getSspaPath,
getPOMPath,
execCommand,
};