Skip to content

Commit

Permalink
Update execute.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
rozenmd committed May 30, 2023
1 parent de409e3 commit 20cc1a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/wrangler/src/d1/execute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ export async function executeSql({
json: boolean | undefined;
preview: boolean | undefined;
}) {
const existingLogLevel = logger.loggerLevel;
if (json) {
// set loggerLevel to error to avoid logs appearing in JSON output
logger.loggerLevel = "error";
}
const sql = file ? readFileSync(file) : command;
if (!sql) throw new Error(`Error: must provide --command or --file.`);
if (preview && local)
Expand All @@ -178,8 +183,7 @@ export async function executeSql({
);
}
}

return local
const result = local
? await executeLocally({
config,
name,
Expand All @@ -196,6 +200,8 @@ export async function executeSql({
json,
preview,
});
if (json) logger.loggerLevel = existingLogLevel;
return result;
}

async function executeLocally({
Expand Down

0 comments on commit 20cc1a1

Please sign in to comment.