Skip to content

Commit 88a8dff

Browse files
authored
fix: checking if the project's azion.config exists (#388)
1 parent 5fb9d2d commit 88a8dff

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/build/dispatcher/dispatcher.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,8 @@ class Dispatcher {
547547

548548
// merge azion.config.js user with preset azion.config.js
549549
const customizer = (objValue, srcValue) => {
550-
if (Array.isArray(objValue)) {
551-
const map = new Map();
552-
objValue.concat(srcValue).forEach((item) => {
553-
if (item && item.name) {
554-
map.set(item.name, item);
555-
}
556-
});
557-
return Array.from(map.values());
550+
if (objValue && !objValue.build) {
551+
return srcValue;
558552
}
559553
return undefined;
560554
};
@@ -566,7 +560,7 @@ class Dispatcher {
566560
customizer,
567561
);
568562

569-
if (!configModule) {
563+
if (!azionConfigModule) {
570564
await vulcan.createAzionConfigFile(isCommonJS(), configModule);
571565
}
572566

lib/env/vulcan.env.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async function createAzionConfigFile(useCommonJS, module) {
240240
);
241241

242242
const formattedContent = await prettier.format(
243-
`${moduleExportStyle} ${jsonString};`,
243+
`${moduleExportStyle} defineConfig(${jsonString});`,
244244
{
245245
parser: 'babel',
246246
semi: false,
@@ -249,8 +249,14 @@ async function createAzionConfigFile(useCommonJS, module) {
249249
},
250250
);
251251

252+
const importStatement = useCommonJS
253+
? "const { defineConfig } = require('azion');\n\n"
254+
: "import { defineConfig } from 'azion';\n\n";
255+
256+
const finalContent = `${importStatement}${formattedContent}`;
257+
252258
if (!fs.existsSync(configPath)) {
253-
await fsPromises.writeFile(configPath, formattedContent);
259+
await fsPromises.writeFile(configPath, finalContent);
254260
}
255261
}
256262

0 commit comments

Comments
 (0)