-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepush.mjs
30 lines (26 loc) · 936 Bytes
/
prepush.mjs
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
import fs from 'node:fs';
// Define the path to the folder
const folderPath = './dist';
const filePath = './dist/index.html';
// Check if the folder exists
fs.access(filePath, fs.constants.F_OK, (err) => {
if (err) {
throw (new Error('Index.html file does not exist. Please run "npm run build" first and then try to push again...'));
// Execute the npm script
/* exec(npmScript, (error, stdout, stderr) => {
if (error) {
console.error(`Error executing npm script: ${error}`);
return;
}
// Log the output of the script
console.log(`stdout: ${stdout}`);
// console.error(`stderr: ${stderr}`);
console.log(`Please try to add new files and then push again...`)
// throw (new Error(`Error executing git push`));
return;
}); */
} else {
console.log(`Dist folder with Index.html exists. Continuing pushing the files to github...`)
return;
}
});