-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpostbuild-copy-files.js
27 lines (24 loc) · 1.02 KB
/
postbuild-copy-files.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
/**
* This is a post-build script used to copy the `proxy-server.js`
* file into the built application in the `dist/app` folder.
* If the file already exists, it will be overwritten.
*/
const fs = require('fs');
const path = require('path');
// Define source and destination paths
const sourcePath = path.join(__dirname, 'proxy-server.js');
const destinationDir = path.join(__dirname, 'dist/app');
const destinationPath = path.join(destinationDir, 'proxy-server.js');
try {
// Check if destination directory exists
if (!fs.existsSync(destinationDir)) {
console.error(`Post-build file copy: Destination folder ${destinationDir} does not exist. Skipping file copy.`);
process.exit(1); // Exit with a non-zero code to indicate an issue
}
// Copy the file
fs.copyFileSync(sourcePath, destinationPath);
console.log(`Post-build file copy: File successfully copied.`);
} catch (error) {
console.error('Post-build file copy: Error copying file.', error);
process.exit(1); // Exit with a non-zero code to indicate an issue
}