create-slidev 0.47.0 → 0.47.1

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 CHANGED
@@ -1,31 +1,36 @@
1
- import { copyFileSync, existsSync, mkdirSync, rmSync } from 'node:fs'
2
- import * as url from 'node:url'
3
- import { resolve } from 'node:path'
1
+ import { fileURLToPath } from 'node:url'
2
+ import { dirname, resolve } from 'node:path'
3
+ import fs from 'fs-extra'
4
4
 
5
- const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
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
- mkdirSync(__pagesDir)
21
- Object.keys(needCopyFiles).forEach((relativeTargetPath) => {
22
- const sourcePath = resolve(__templateDir, needCopyFiles[relativeTargetPath])
23
- const targetPath = resolve(__templateDir, relativeTargetPath)
24
- const exist = existsSync(targetPath)
25
- if (exist)
26
- rmSync(targetPath)
27
- copyFileSync(sourcePath, targetPath)
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-slidev",
3
3
  "type": "module",
4
- "version": "0.47.0",
4
+ "version": "0.47.1",
5
5
  "description": "Create starter template for Slidev",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "export": "slidev export"
9
9
  },
10
10
  "dependencies": {
11
- "@slidev/cli": "^0.47.0",
11
+ "@slidev/cli": "^0.47.1",
12
12
  "@slidev/theme-default": "latest",
13
13
  "@slidev/theme-seriph": "latest"
14
14
  }
@@ -0,0 +1,9 @@
1
+ /* eslint-disable no-console */
2
+
3
+ // #region snippet
4
+ function hello() {
5
+ console.log('Hello from snippets/external.ts')
6
+ }
7
+ // #endregion snippet
8
+
9
+ export default hello