refactor: 简化 dailyVersioning 插件实现
This commit is contained in:
@@ -9,18 +9,10 @@ function dailyVersioning() {
|
||||
name: 'daily-versioning',
|
||||
enforce: 'post',
|
||||
writeBundle(options, bundle) {
|
||||
const now = new Date()
|
||||
const date = now.getFullYear()
|
||||
+ String(now.getMonth() + 1).padStart(2, '0')
|
||||
+ String(now.getDate()).padStart(2, '0')
|
||||
|
||||
const oldPath = join(options.dir || 'dist', 'index.html')
|
||||
const newName = `grandclaw-archtype-${date}.html`
|
||||
const newPath = join(options.dir || 'dist', newName)
|
||||
|
||||
if (bundle['index.html']) {
|
||||
renameSync(oldPath, newPath)
|
||||
}
|
||||
if (!bundle['index.html']) return
|
||||
const dir = options.dir || 'dist'
|
||||
const date = new Date().toISOString().slice(0, 10).replace(/-/g, '')
|
||||
renameSync(join(dir, 'index.html'), join(dir, `grandclaw-archtype-${date}.html`))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user