create-slidev 0.47.0 → 0.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.mjs +20 -15
- package/package.json +1 -1
- package/template/package.json +1 -1
- package/template/snippets/external.ts +9 -0
package/build.mjs
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { dirname, resolve } from 'node:path'
|
|
3
|
+
import fs from 'fs-extra'
|
|
4
4
|
|
|
5
|
-
const __dirname =
|
|
5
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
6
6
|
const __templateDir = resolve(__dirname, 'template')
|
|
7
7
|
const __pagesDir = resolve(__templateDir, 'pages')
|
|
8
8
|
|
|
9
|
-
const shouldCreatePagesDict = () => !existsSync(__pagesDir)
|
|
9
|
+
const shouldCreatePagesDict = () => !fs.existsSync(__pagesDir)
|
|
10
10
|
|
|
11
11
|
// key: copy to (relative ./)
|
|
12
12
|
// value: origin (relative ./template)
|
|
13
13
|
const needCopyFiles = {
|
|
14
14
|
'slides.md': '../../../demo/starter/slides.md',
|
|
15
15
|
'pages/multiple-entries.md': '../../../demo/starter/pages/multiple-entries.md',
|
|
16
|
+
'snippets/external.ts': '../../../demo/starter/snippets/external.ts',
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
function main() {
|
|
19
|
+
async function main() {
|
|
19
20
|
if (shouldCreatePagesDict())
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
await fs.ensureDir(__pagesDir)
|
|
22
|
+
|
|
23
|
+
await Promise.all(
|
|
24
|
+
Object.keys(needCopyFiles).map(async (relativeTargetPath) => {
|
|
25
|
+
const sourcePath = resolve(__templateDir, needCopyFiles[relativeTargetPath])
|
|
26
|
+
const targetPath = resolve(__templateDir, relativeTargetPath)
|
|
27
|
+
if (fs.existsSync(targetPath))
|
|
28
|
+
await fs.rm(targetPath)
|
|
29
|
+
|
|
30
|
+
await fs.ensureDir(dirname(targetPath))
|
|
31
|
+
await fs.copy(sourcePath, targetPath)
|
|
32
|
+
}),
|
|
33
|
+
)
|
|
29
34
|
// eslint-disable-next-line no-console
|
|
30
35
|
console.log('done...')
|
|
31
36
|
}
|
package/package.json
CHANGED
package/template/package.json
CHANGED