@best-shot/preset-mini 0.4.23 → 0.4.24

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.
Files changed (3) hide show
  1. package/helper.mjs +14 -2
  2. package/index.mjs +1 -1
  3. package/package.json +5 -5
package/helper.mjs CHANGED
@@ -3,8 +3,20 @@ import { resolve } from 'node:path';
3
3
 
4
4
  import { parse } from 'yaml';
5
5
 
6
- export function readYAML(path, base = process.cwd()) {
7
- const file = readFileSync(resolve(base, path), 'utf8');
6
+ function read(base, name) {
7
+ try {
8
+ return readFileSync(resolve(base, name), 'utf8');
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ export function readYAML(base = process.cwd()) {
15
+ const file =
16
+ read(base, 'app.yaml') ||
17
+ read(base, 'app.yml') ||
18
+ read(base, 'app.json') ||
19
+ {};
8
20
 
9
21
  return parse(file);
10
22
  }
package/index.mjs CHANGED
@@ -56,7 +56,7 @@ export function apply({
56
56
  if (appConfig) {
57
57
  chain.entry('app').add('./app.js');
58
58
 
59
- const io = readYAML('app.yaml', context);
59
+ const io = readYAML(context);
60
60
  const allPages = getAllPages(io);
61
61
 
62
62
  for (const page of allPages) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@best-shot/preset-mini",
3
- "version": "0.4.23",
3
+ "version": "0.4.24",
4
4
  "description": "A `best-shot` preset for mini program project",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -28,13 +28,13 @@
28
28
  "main": "index.mjs",
29
29
  "type": "module",
30
30
  "dependencies": {
31
- "yaml": "^2.5.0",
32
- "@best-shot/sfc-split-plugin": "~0.6.10"
31
+ "yaml": "^2.5.1",
32
+ "@best-shot/sfc-split-plugin": "~0.6.12"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@best-shot/core": "~0.10.4",
36
- "@best-shot/preset-babel": "~0.15.7",
37
- "@best-shot/preset-style": "~0.13.3"
36
+ "@best-shot/preset-style": "~0.13.3",
37
+ "@best-shot/preset-babel": "~0.15.7"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=22.0.0 || ^18.20.4 || ^20.15.0"