c12 1.11.0 → 1.11.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/dist/update.cjs +8 -4
- package/dist/update.mjs +8 -4
- package/package.json +1 -1
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(
|
|
21
|
-
|
|
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 })
|
|
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,
|
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(
|
|
19
|
-
|
|
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 })
|
|
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,
|