-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_rename.js
33 lines (27 loc) · 986 Bytes
/
script_rename.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
28
29
30
31
32
33
// create out directory for static Chrome Extension
const fs = require('fs');
const glob = require('glob');
const files = glob.sync('out/**/*.html');
files.forEach((file) => {
let content = fs.readFileSync(file, 'utf-8');
content = content.replace(/\/_next/g, './next');
fs.writeFileSync(file, content, 'utf-8');
});
const sourcePath = 'out/_next';
const destinationPath = 'out/next';
fs.rename(sourcePath, destinationPath, (err) => {
if (err) {
console.error('Failed to rename "_next" directory to "next".', err);
} else {
console.log('Renamed "_next" directory to "next" successfully.');
}
});
const sourcePathPopup = 'out/popup/index.html';
const destinationPathPopup = 'out/index.html';
fs.rename(sourcePathPopup, destinationPathPopup, (err) => {
if (err) {
console.error('Failed to rename "popup/index.html" directory to "index.html".', err);
} else {
console.log('Renamed "popup/index.html" directory to "index.html" successfully.');
}
});