48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
// boot_link.js
|
|
const fs = require('fs')
|
|
const { execSync } = require('child_process')
|
|
const path = require('path')
|
|
|
|
// Main function to link libraries
|
|
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) {
|
|
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'
|
|
)
|
|
|
|
libs.forEach(libName => {
|
|
const libPath = path.join(openSharePath, 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)
|
|
})
|
|
}
|
|
})
|