Skip to content

Commit 498f356

Browse files
committed
Reduce nesting
1 parent 2b3ed7d commit 498f356

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pixel.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,20 @@ function removeFolder( relativePath ) {
163163
}
164164

165165
async function updateCodexRepoBranchIfNecessary( opts, mwBranch ) {
166-
// If the user hasn't specified a '--repo-branch' for codex
167-
// determine which version the MW branch wants and use it
168-
if ( !opts.repoBranch?.some( ( branch ) => branch.startsWith( 'design/codex:' ) ) ) {
169-
let codexVersion;
170-
try {
171-
codexVersion = await getCodexVersionForMWBranch( mwBranch );
172-
} catch ( error ) {
173-
codexVersion = await getLatestCodexVersion();
174-
console.log( `\x1b[33m${error.message}Falling back to latest Codex version ${codexVersion}\x1b[0m` );
175-
}
176-
opts.repoBranch = [ ...( opts.repoBranch ?? [] ), `design/codex:${codexVersion}` ];
166+
// Return if the user has already specified a '--repo-branch' for Codex
167+
if ( opts.repoBranch?.some( ( branch ) => branch.startsWith( 'design/codex:' ) ) ) {
168+
return;
169+
}
170+
// Determine which Codex version the MW branch wants and use it,
171+
// fallback on latest version
172+
let codexVersion;
173+
try {
174+
codexVersion = await getCodexVersionForMWBranch( mwBranch );
175+
} catch ( error ) {
176+
codexVersion = await getLatestCodexVersion();
177+
console.log( `\x1b[33m${error.message}Falling back to latest Codex version ${codexVersion}\x1b[0m` );
177178
}
179+
opts.repoBranch = [ ...( opts.repoBranch ?? [] ), `design/codex:${codexVersion}` ];
178180
}
179181

180182
/**

0 commit comments

Comments
 (0)