diff --git a/packages/theme/build/edit‐dir‐theme.js b/packages/theme/build/edit‐dir‐theme.js index 319792148..c300e286c 100644 --- a/packages/theme/build/edit‐dir‐theme.js +++ b/packages/theme/build/edit‐dir‐theme.js @@ -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) + } } }) }