35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
/**
|
|
*
|
|
* 自定义nodejs 脚本
|
|
* 目的: 将公共组件复制到本地项目的组件包内,用于完成打包操作。
|
|
* 注意: cpSync函数新增于: node v16.7.0
|
|
*
|
|
* @author terrfly
|
|
* @site https://www.jeequan.com
|
|
* @date 2022/1/26 16:01
|
|
**
|
|
*/
|
|
const path = require('path')
|
|
const fs = require('fs')
|
|
|
|
// 根据实际项目名称进行变更
|
|
const componentName = 'JeepayUIComponents' // 公共项目的项目名称
|
|
|
|
|
|
const componentDir = path.resolve(`../jeepay-ui-manager/src/components/${componentName}/`) // 公共项目的文件地址
|
|
const copyDir = path.resolve(`./src/components/link/${componentName}/`) // 需要复制的文件地址 (需要注意加入到git ignore 中)
|
|
|
|
if(!fs.existsSync(componentDir)){
|
|
throw new Error(`请检查公共项目[ ${componentName} ]是否正确下载! `)
|
|
}
|
|
|
|
// 删除文件夹
|
|
if(fs.existsSync(copyDir)){
|
|
fs.rmSync(copyDir, {recursive: true})
|
|
}
|
|
|
|
// 复制文件夹到项目中
|
|
fs.cpSync(componentDir, copyDir, { recursive: true })
|
|
|
|
console.log(`公共项目[ ${componentName} ]安装完成!`)
|