build(theme): [theme] Add the index.less file package of the root directory (#1090)

This commit is contained in:
chenxi-20 2023-12-11 14:54:39 +08:00 committed by GitHub
parent 18e90ec163
commit 7fb4317d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 13 deletions

View File

@ -1,4 +1,4 @@
const fs = require('fs')
const fs = require('node:fs')
const fsExtra = require('fs-extra')
const indexLessPath = 'index.less'
const indexJsPath = 'index.js'
@ -109,8 +109,18 @@ const createTheme = (callbackFn) => {
}, 20)
}
const copyDir = (originPath, targetPath) => {
fsExtra.copy(originPath, targetPath, (err) => {
if (err) {
console.log(err)
}
})
}
const mkStat = (originPath, fileDir, type) => {
const statPath = `${originPath}/${fileDir}`
const smbPath = `${originPath}/smb-theme/${fileDir}`
const auroraPath = `${originPath}/aurora-theme/${fileDir}`
fs.stat(statPath, (err, data) => {
if (err) {
console.log('mkStat', err)
@ -119,22 +129,17 @@ const createTheme = (callbackFn) => {
if (data.isDirectory()) {
if (fileDir !== 'base' && fileDir !== 'theme') {
if (fileDir === 'images') {
fsExtra.copy(statPath, `${originPath}/smb-theme/${fileDir}`, (subErr) => {
if (subErr) {
console.log(subErr)
return
}
})
fsExtra.copy(statPath, `${originPath}/aurora-theme/${fileDir}`, (subErr) => {
if (subErr) {
console.log(subErr)
return
}
})
copyDir(statPath, smbPath)
copyDir(statPath, auroraPath)
} else {
isFileExist(originPath, fileDir, type)
}
}
} else {
if (fileDir === 'index.less') {
copyDir(statPath, smbPath)
copyDir(statPath, auroraPath)
}
}
})
}