mirror of
https://github.com/mmahdium/portfolio.git
synced 2026-08-14 12:12:48 +03:30
feat: enhance blog components, improve routing, and add clean script for build process
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import fs from 'node:fs'
|
||||
|
||||
const pathsToRemove = ['.nuxt', '.output']
|
||||
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
||||
|
||||
async function rmWithRetry(path, retries = 10) {
|
||||
for (let attempt = 0; attempt <= retries; attempt++) {
|
||||
try {
|
||||
fs.rmSync(path, { recursive: true, force: true })
|
||||
return
|
||||
} catch (error) {
|
||||
const code = error?.code
|
||||
const shouldRetry = code === 'EBUSY' || code === 'EPERM'
|
||||
|
||||
if (!shouldRetry || attempt === retries) {
|
||||
console.error(
|
||||
`[clean] Failed to remove "${path}".\n` +
|
||||
`Close any running "nuxt preview" / dev servers using it, then rerun.\n` +
|
||||
`Error: ${code || error}`
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await sleep(250)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const path of pathsToRemove) {
|
||||
await rmWithRetry(path)
|
||||
}
|
||||
Reference in New Issue
Block a user