-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathout.js
29 lines (26 loc) · 924 Bytes
/
out.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
const fs = require('fs');
const fsExtra = require('fs-extra');
const glob = require('glob');
const path = require('path');
const files = glob.sync('out/**/*.html');
files.forEach((file) => {
const content = fs.readFileSync(file, 'utf-8');
const modifiedContent = content.replace(/\/_next/g, './next');
fs.writeFileSync(file, modifiedContent, 'utf-8');
});
const sourcePath = path.join('out', '_next');
const destinationPath = path.join('out', 'next');
fsExtra.copy(sourcePath, destinationPath, (err) => {
if (err) {
console.error('Failed to copy "_next" directory to "next".', err);
} else {
console.log('Copied "_next" directory to "next" successfully.');
fsExtra.remove(sourcePath, (err) => {
if (err) {
console.error('Failed to remove original "_next" directory.', err);
} else {
console.log('Removed original "_next" directory successfully.');
}
});
}
});