-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprebuild.mjs
43 lines (39 loc) · 929 Bytes
/
prebuild.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*!
* 11ty prebuild script
*
* https://github.com/equk/
*
* Copyright (c) 2023 B.Walden. All rights reserved.
*
* Licensed under the MIT License
*
* (LICENSE file should be included with script)
*
*/
import fs from 'fs'
const outputDir = 'dist'
async function preEleventy() {
// Start time for cli stats
const start = +new Date()
console.log('[pre-11ty] Starting Clean Build')
// Clean output if exists
if (fs.existsSync(outputDir)) {
fs.rmSync(outputDir, { recursive: true })
console.log(`[pre-11ty] Cleaning Old Build From ${outputDir}`)
const end = +new Date()
console.log(
`[pre-11ty] Build Output: '${outputDir}' Removed (+${end - start}ms)`
)
} else {
console.log(`[pre-11ty] Build Output: '${outputDir}' is clean`)
}
console.log('\n')
}
/*
* Run Main Function
*/
preEleventy().catch((error) => {
console.error(error)
// quit if error
process.exit(1)
})