-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.js
More file actions
54 lines (48 loc) · 1.38 KB
/
commands.js
File metadata and controls
54 lines (48 loc) · 1.38 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
48
49
50
51
52
53
54
const argv = require("minimist-lite")(process.argv.slice(2));
const shell = require("shelljs");
const axios = require("axios");
const fsp = require("fs/promises");
async function syncConfigFiles() {
const urlAndPath = [
{
url: "https://myplaceportal.uk/api/config",
path: "./src/assets/config/myplaceportal_uk.json",
},
{
url: "https://www.myplaceportal.uk/api/config",
path: "./src/assets/config/www_myplaceportal_uk.json",
},
];
for (const item of urlAndPath) {
try {
const { data } = await axios.get(item.url);
await fsp.writeFile(item.path, JSON.stringify(data));
} catch (e) {
console.log(e);
}
}
}
/**
* Prepares Husky by setting up hooks and ensuring they have the right permissions,
* skipping setup in CI environments.
*/
function prepareHusky() {
// Cross-platform environment check to skip Husky setup if running in a CI environment
if (process.env.CI === "true") {
return;
}
// Execute Husky setup and permission changes, ensuring hooks are executable
const result = shell.exec("husky && bash -c 'chmod ug+x .husky/*'");
if (result.code !== 0) {
console.error("Error running Husky or setting permissions:", result.stderr);
process.exit(result.code);
}
}
switch (argv.command) {
case "conf-sync":
syncConfigFiles();
break;
case "prepare":
prepareHusky();
break;
}