mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Fix: make public dir before copy
This commit is contained in:
parent
cec811a629
commit
1509fef647
@ -1,4 +1,5 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import fsp from 'fs/promises';
|
||||
import { task } from './trace';
|
||||
import { treeDir } from './lib/tree-dir';
|
||||
@ -23,6 +24,8 @@ const folderAndFilesToBeDeployed = [
|
||||
];
|
||||
|
||||
export const buildPublic = task(typeof Bun !== 'undefined' ? Bun.main === __filename : require.main === module, __filename)(async (span) => {
|
||||
fs.mkdirSync(publicPath, { recursive: true });
|
||||
|
||||
await span
|
||||
.traceChild('copy public files')
|
||||
.traceAsyncFn(async () => {
|
||||
@ -43,7 +46,16 @@ export const buildPublic = task(typeof Bun !== 'undefined' ? Bun.main === __file
|
||||
const src = path.join(rootPath, file);
|
||||
const dest = path.join(publicPath, file);
|
||||
|
||||
return fsp.copyFile(src, dest);
|
||||
const destParen = path.dirname(dest);
|
||||
if (!fs.existsSync(destParen)) {
|
||||
fs.mkdirSync(destParen, { recursive: true });
|
||||
}
|
||||
|
||||
return fsp.copyFile(
|
||||
src,
|
||||
dest,
|
||||
fs.constants.COPYFILE_FICLONE
|
||||
);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user