Skip to content

Commit e40448f

Browse files
authored
Merge branch 'feature/extensibility-v2' into feature/@W-18895152@/update-next-with-v4
2 parents a53369a + 3413187 commit e40448f

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

packages/pwa-kit-create-app/scripts/create-mobify-app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,9 @@ const main = async (opts) => {
886886
process.exit(1)
887887
}
888888

889-
if (presetId && !context.preset) {
890-
context.preset = PRESETS.find(({id}) => id === presetId)
889+
// If no preset is provided, use the first preset or the preset specified by the GENERATOR_PRESET environment variable
890+
if (!context.preset) {
891+
context.preset = presetId ? PRESETS.find(({id}) => id === presetId) : PRESETS[0]
891892
}
892893

893894
const {interactive = false, getQuestions, answers = {}} = context.preset

packages/pwa-kit-create-app/scripts/trim-extensions.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,19 @@ function processFile(filePath, plugins) {
210210

211211
// Only write output if we made changes
212212
if (modified) {
213-
// Generate code from modified AST
214-
const output = generate(ast, {
215-
retainLines: true,
216-
compact: false
217-
}).code
218-
219-
// console.log(JSON.stringify(output.split('\n').slice(0, 100), null, 2));
220-
221-
// Replace the original file with the trimmed version
222-
fs.writeFileSync(filePath, output)
223-
console.log(`Updated file ${filePath}`)
213+
try {
214+
// Generate code from modified AST
215+
const output = generate(ast, {
216+
retainLines: true,
217+
compact: false
218+
}).code
219+
// Replace the original file with the trimmed version
220+
fs.writeFileSync(filePath, output)
221+
console.log(`Updated file ${filePath}`)
222+
} catch (e) {
223+
console.error(`Error updating file ${filePath}: ${e.message}`)
224+
throw e
225+
}
224226
}
225227
}
226228

0 commit comments

Comments
 (0)