u
This commit is contained in:
@@ -6,6 +6,7 @@ const path = require('path')
|
||||
const openSharePath = fs.existsSync(path.resolve('./env_loc.gitomit.sfomit.json')) ? require(path.resolve('./env_loc.gitomit.sfomit.json')).openShare : ''
|
||||
console.log('openShare:', openSharePath)
|
||||
if (!openSharePath) {
|
||||
console.log('openShare not found, exiting now.')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -22,7 +23,7 @@ libs.forEach((libName) => {
|
||||
const sourceFiles = fs.readdirSync(libPath).filter((fileName) => fileName.endsWith('.js') || fileName.endsWith('.json'))
|
||||
sourceFiles.forEach((file) => {
|
||||
const sourceFile = path.join(libPath, file)
|
||||
const tempFile = path.join(nodeModulesPath, libName, file + '.temp')
|
||||
const tempFile = path.join(nodeModulesPath, libName, file + `.${Date.now()}`)
|
||||
const destFile = path.join(nodeModulesPath, libName, file)
|
||||
// fs.symlinkSync(sourceFile, tempFile, 'file') // through symbolic links, 例如 tic-crypto 安装后,报错 tweetnacl module 找不到,因为跟着 symbolic links 去原始文件所在的位置找了。
|
||||
try {
|
||||
@@ -32,6 +33,9 @@ libs.forEach((libName) => {
|
||||
// Fallback to copy if hard link fails
|
||||
fs.copyFileSync(sourceFile, tempFile)
|
||||
}
|
||||
try {
|
||||
fs.unlinkSync(destFile)
|
||||
} catch {}
|
||||
fs.renameSync(tempFile, destFile)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user