build: 📦️ fallback to root "src" dir when "global" dir not exists

This commit is contained in:
bubkoo
2021-03-23 01:43:34 +08:00
committed by 问崖
parent ed9e94283d
commit de1c84d0b8

View File

@ -13,7 +13,10 @@ const version = '${version}'
export { version }
`
const file = 'src/global/version.ts'
const dir = 'src/global'
const hasDir = fs.existsSync(dir)
const name = 'version.ts'
const file = hasDir ? `${dir}/${name}` : `src/${name}`
const old = fs.readFileSync(file, { encoding: 'utf8' })
const format = (s) => s.replace(/[\n\s]/g, '')