c12 1.11.0 → 1.11.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/dist/update.cjs CHANGED
@@ -17,8 +17,12 @@ require('dotenv');
17
17
  const UPDATABLE_EXTS = [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts"];
18
18
  async function updateConfig(opts) {
19
19
  const { parseModule } = await import('magicast');
20
- let configFile = await _tryResolve(opts.configFile, opts.cwd, loader.SUPPORTED_EXTENSIONS) || await _tryResolve(
21
- `.config/${opts.configFile}`,
20
+ let configFile = await _tryResolve(
21
+ `./${opts.configFile}`,
22
+ opts.cwd,
23
+ loader.SUPPORTED_EXTENSIONS
24
+ ) || await _tryResolve(
25
+ `./.config/${opts.configFile}`,
22
26
  opts.cwd,
23
27
  loader.SUPPORTED_EXTENSIONS
24
28
  );
@@ -28,7 +32,7 @@ async function updateConfig(opts) {
28
32
  opts.cwd,
29
33
  opts.configFile + (opts.createExtension || ".ts")
30
34
  );
31
- const createResult = await opts.onCreate?.({ configFile }) || true;
35
+ const createResult = await opts.onCreate?.({ configFile }) ?? true;
32
36
  if (!createResult) {
33
37
  throw new Error("Config file creation aborted.");
34
38
  }
@@ -51,7 +55,7 @@ async function updateConfig(opts) {
51
55
  throw new Error("Default export is missing in the config file!");
52
56
  }
53
57
  const configObj = defaultExport.$type === "function-call" ? defaultExport.$args[0] : defaultExport;
54
- opts.onUpdate?.(configObj);
58
+ await opts.onUpdate?.(configObj);
55
59
  await promises.writeFile(configFile, _module.generate().code);
56
60
  return {
57
61
  configFile,
@@ -60,7 +64,7 @@ async function updateConfig(opts) {
60
64
  }
61
65
  function _tryResolve(path, cwd, exts) {
62
66
  return mlly.resolvePath(path, {
63
- url: cwd,
67
+ url: pathe.join(cwd, "_index.js"),
64
68
  extensions: exts
65
69
  }).catch(() => void 0);
66
70
  }
package/dist/update.mjs CHANGED
@@ -15,8 +15,12 @@ import 'dotenv';
15
15
  const UPDATABLE_EXTS = [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts"];
16
16
  async function updateConfig(opts) {
17
17
  const { parseModule } = await import('magicast');
18
- let configFile = await _tryResolve(opts.configFile, opts.cwd, SUPPORTED_EXTENSIONS) || await _tryResolve(
19
- `.config/${opts.configFile}`,
18
+ let configFile = await _tryResolve(
19
+ `./${opts.configFile}`,
20
+ opts.cwd,
21
+ SUPPORTED_EXTENSIONS
22
+ ) || await _tryResolve(
23
+ `./.config/${opts.configFile}`,
20
24
  opts.cwd,
21
25
  SUPPORTED_EXTENSIONS
22
26
  );
@@ -26,7 +30,7 @@ async function updateConfig(opts) {
26
30
  opts.cwd,
27
31
  opts.configFile + (opts.createExtension || ".ts")
28
32
  );
29
- const createResult = await opts.onCreate?.({ configFile }) || true;
33
+ const createResult = await opts.onCreate?.({ configFile }) ?? true;
30
34
  if (!createResult) {
31
35
  throw new Error("Config file creation aborted.");
32
36
  }
@@ -49,7 +53,7 @@ async function updateConfig(opts) {
49
53
  throw new Error("Default export is missing in the config file!");
50
54
  }
51
55
  const configObj = defaultExport.$type === "function-call" ? defaultExport.$args[0] : defaultExport;
52
- opts.onUpdate?.(configObj);
56
+ await opts.onUpdate?.(configObj);
53
57
  await writeFile(configFile, _module.generate().code);
54
58
  return {
55
59
  configFile,
@@ -58,7 +62,7 @@ async function updateConfig(opts) {
58
62
  }
59
63
  function _tryResolve(path, cwd, exts) {
60
64
  return resolvePath(path, {
61
- url: cwd,
65
+ url: join(cwd, "_index.js"),
62
66
  extensions: exts
63
67
  }).catch(() => void 0);
64
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c12",
3
- "version": "1.11.0",
3
+ "version": "1.11.2",
4
4
  "description": "Smart Config Loader",
5
5
  "repository": "unjs/c12",
6
6
  "license": "MIT",
@@ -46,22 +46,22 @@
46
46
  "ohash": "^1.1.3",
47
47
  "pathe": "^1.1.2",
48
48
  "perfect-debounce": "^1.0.0",
49
- "pkg-types": "^1.1.1",
49
+ "pkg-types": "^1.2.0",
50
50
  "rc9": "^2.1.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/node": "^20.14.2",
54
- "@vitest/coverage-v8": "^1.6.0",
55
- "automd": "^0.3.7",
53
+ "@types/node": "^22.5.2",
54
+ "@vitest/coverage-v8": "^2.0.5",
55
+ "automd": "^0.3.8",
56
56
  "changelogen": "^0.5.5",
57
- "eslint": "^9.4.0",
57
+ "eslint": "^9.9.1",
58
58
  "eslint-config-unjs": "^0.3.2",
59
- "expect-type": "^0.19.0",
60
- "magicast": "^0.3.4",
61
- "prettier": "^3.3.2",
62
- "typescript": "^5.4.5",
59
+ "expect-type": "^0.20.0",
60
+ "magicast": "^0.3.5",
61
+ "prettier": "^3.3.3",
62
+ "typescript": "^5.5.4",
63
63
  "unbuild": "^2.0.0",
64
- "vitest": "^1.6.0"
64
+ "vitest": "^2.0.5"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "magicast": "^0.3.4"