Skip to content

Commit 5081733

Browse files
committed
address bot
1 parent 2c5b332 commit 5081733

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/@apphosting/adapter-nextjs/e2e/config-override.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("next.config override", () => {
5757
const standaloneConfigFiles = standaloneFiles.filter((file) => file.match(configRegex));
5858
assert.strictEqual(standaloneConfigFiles.length, 2);
5959
assert.ok(
60-
configFiles.some((file) => file.match(configOriginalRegex)),
60+
standaloneConfigFiles.some((file) => file.match(configOriginalRegex)),
6161
"no original config found in standalone",
6262
);
6363
});

packages/@apphosting/adapter-nextjs/src/overrides.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,27 +147,22 @@ export async function validateNextConfigOverride(
147147
* to leave user code the way we found it.
148148
*/
149149
export async function restoreNextConfig(projectRoot: string, nextConfigFileName: string) {
150-
// Check if the file exists in the current working directory
151-
const configPath = join(projectRoot, nextConfigFileName);
152-
if (!(await exists(configPath))) {
153-
return;
154-
}
155-
156150
// Determine the file extension
157151
const fileExtension = extname(nextConfigFileName);
158152
const originalConfigPath = join(projectRoot, `next.config.original${fileExtension}`);
153+
159154
if (!(await exists(originalConfigPath))) {
160-
console.warn(`next config may have been overwritten but original contents not found`);
155+
// No backup file found, nothing to restore.
161156
return;
162157
}
163158
console.log(`Restoring original next config in project root`);
164159

160+
const configPath = join(projectRoot, nextConfigFileName);
165161
try {
166162
await renamePromise(originalConfigPath, configPath);
167163
} catch (error) {
168164
console.error(`Error restoring Next config: ${error}`);
169165
}
170-
return;
171166
}
172167

173168
/**

0 commit comments

Comments
 (0)