@slidev/cli 0.48.0-beta.0 → 0.48.0-beta.10

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.
@@ -2,29 +2,17 @@
2
2
  import { resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import fs from "fs-extra";
5
- import { isObject } from "@antfu/utils";
5
+ import { deepMergeWithArray } from "@antfu/utils";
6
6
  import jiti from "jiti";
7
- function deepMerge(a, b, rootPath = "") {
8
- a = { ...a };
9
- Object.keys(b).forEach((key) => {
10
- if (isObject(a[key]))
11
- a[key] = deepMerge(a[key], b[key], rootPath ? `${rootPath}.${key}` : key);
12
- else if (Array.isArray(a[key]))
13
- a[key] = [...a[key], ...b[key]];
14
- else
15
- a[key] = b[key];
16
- });
17
- return a;
18
- }
19
- async function loadSetups(roots, name, arg, initial, merge = true) {
7
+ async function loadSetups(clientRoot, roots, name, arg, initial, merge = true) {
20
8
  let returns = initial;
21
- for (const root of roots) {
9
+ for (const root of [clientRoot, ...roots].reverse()) {
22
10
  const path = resolve(root, "setup", name);
23
11
  if (fs.existsSync(path)) {
24
12
  const { default: setup } = jiti(fileURLToPath(import.meta.url))(path);
25
13
  const result = await setup(arg);
26
14
  if (result !== null) {
27
- returns = typeof merge === "function" ? merge(returns, result) : merge ? deepMerge(returns, result) : result;
15
+ returns = typeof merge === "function" ? merge(returns, result) : merge ? deepMergeWithArray(returns, result) : result;
28
16
  }
29
17
  }
30
18
  }