add 'boot_link.js'
This commit is contained in:
parent
4aa5a23864
commit
1665611cd5
46
boot_link.js
Normal file
46
boot_link.js
Normal file
@ -0,0 +1,46 @@
|
||||
// boot_link.js
|
||||
const fs = require('fs')
|
||||
const { execSync } = require('child_process')
|
||||
const path = require('path')
|
||||
|
||||
// Main function to link libraries
|
||||
const openNpmPath = fs.existsSync(path.resolve('./env_loc.gitomit.sfomit.json'))
|
||||
? require(path.resolve('./env_loc.gitomit.sfomit.json')).openNpm
|
||||
: ''
|
||||
console.log('openNpm:', openNpmPath)
|
||||
if (!openNpmPath) {
|
||||
return
|
||||
}
|
||||
|
||||
const nodeModulesPath = path.resolve('./node_modules')
|
||||
console.log('nodeModulesPath:', nodeModulesPath)
|
||||
|
||||
// Get the list of libraries
|
||||
const libs = fs
|
||||
.readdirSync(nodeModulesPath)
|
||||
.filter(
|
||||
libName =>
|
||||
libName.startsWith('wo_') ||
|
||||
libName.startsWith('wo-') ||
|
||||
libName === 'tic-crypto'
|
||||
)
|
||||
console.log('libs:', libs)
|
||||
|
||||
libs.forEach(libName => {
|
||||
const libPath = path.join(openNpmPath, libName)
|
||||
if (fs.existsSync(libPath)) {
|
||||
console.log(`Copying ${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 destFile = path.join(nodeModulesPath, libName, file)
|
||||
fs.symlinkSync(sourceFile, tempFile, 'file')
|
||||
fs.renameSync(tempFile, destFile)
|
||||
})
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user