37 lines
976 B
TypeScript
Raw Normal View History

2022-12-01 22:26:41 +08:00
import fs from 'fs-extra'
import path from 'path'
export const getTime = () => new Date().toLocaleString().split("├")[0]
2022-12-03 20:06:57 +08:00
//symlink同步
export const symlinkCommon = async () => {
const src = path.resolve(__dirname, '../Common')
const dst = path.resolve(__dirname, '../../../client/assets/Scripts/Common')
2022-12-01 22:26:41 +08:00
2022-12-03 20:06:57 +08:00
if (await fs.lstat(dst).then(v => v.isSymbolicLink()).catch(() => false) && await fs.readlink(dst) === src) {
console.log('同步成功!')
} else {
fs.symlink(src, dst).then(() => {
console.log('同步成功!')
}).catch((e) => {
console.log('同步失败!', e)
})
}
}
//copy同步
export const copyCommon = async () => {
const src = path.resolve(__dirname, '../Common')
const dst = path.resolve(__dirname, '../../../client/assets/Scripts/Common')
2022-12-01 22:26:41 +08:00
console.log(src, dst);
// clean
await fs.remove(dst)
//create
await fs.ensureDir(dst)
// copy
await fs.copy(src, dst)
2022-12-03 20:06:57 +08:00
console.log('同步成功!')
}