Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(biome): fix useless else cases #988

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
},
"style": {
"noParameterAssign": "off",
"noUnusedTemplateLiteral": "off",
"noUselessElse": "off"
"noUnusedTemplateLiteral": "off"
},
"suspicious": {
"noDoubleEquals": "off",
Expand Down
69 changes: 33 additions & 36 deletions docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ const getDefaultOptions = (forRegistry) => {
};
authTokenSet = true;
break;
} else if (configJson.credsStore) {
}
if (configJson.credsStore) {
const helperAuthToken = getCredsFromHelper(
configJson.credsStore,
serverAddress,
Expand Down Expand Up @@ -288,7 +289,8 @@ const getDefaultOptions = (forRegistry) => {
export const getConnection = async (options, forRegistry) => {
if (isContainerd) {
return undefined;
} else if (!dockerConn) {
}
if (!dockerConn) {
const defaultOptions = getDefaultOptions(forRegistry);
const opts = Object.assign(
{},
Expand Down Expand Up @@ -542,29 +544,26 @@ export const getImage = async (fullImageName) => {
console.log(result.stderr);
}
return localData;
} else {
result = spawnSync(dockerCmd, ["inspect", fullImageName], {
encoding: "utf-8",
});
if (result.status !== 0 || result.error) {
console.log(result.stderr);
return localData;
} else {
try {
const stdout = result.stdout;
if (stdout) {
const inspectData = JSON.parse(Buffer.from(stdout).toString());
if (inspectData && Array.isArray(inspectData)) {
return inspectData[0];
} else {
return inspectData;
}
}
} catch (err) {
// continue regardless of error
console.log(err);
}
result = spawnSync(dockerCmd, ["inspect", fullImageName], {
encoding: "utf-8",
});
if (result.status !== 0 || result.error) {
console.log(result.stderr);
return localData;
}
try {
const stdout = result.stdout;
if (stdout) {
const inspectData = JSON.parse(Buffer.from(stdout).toString());
if (inspectData && Array.isArray(inspectData)) {
return inspectData[0];
}
return inspectData;
}
} catch (err) {
// continue regardless of error
console.log(err);
}
}
try {
Expand Down Expand Up @@ -789,17 +788,17 @@ export const exportArchive = async (fullImageName) => {
};
exportData.pkgPathList = getPkgPathList(exportData, lastWorkingDir);
return exportData;
} else if (existsSync(manifestFile)) {
}
if (existsSync(manifestFile)) {
// docker manifest file
return await extractFromManifest(
manifestFile,
{},
tempDir,
allLayersExplodedDir,
);
} else {
console.log(`Unable to extract image archive to ${tempDir}`);
}
console.log(`Unable to extract image archive to ${tempDir}`);
} catch (err) {
console.log(err);
}
Expand Down Expand Up @@ -947,14 +946,13 @@ export const exportImage = async (fullImageName) => {
console.log(result.stdout, result.stderr);
}
return localData;
} else {
await extractTar(imageTarFile, tempDir);
if (DEBUG_MODE) {
console.log(`Cleaning up ${imageTarFile}`);
}
if (rmSync) {
rmSync(imageTarFile, { force: true });
}
}
await extractTar(imageTarFile, tempDir);
if (DEBUG_MODE) {
console.log(`Cleaning up ${imageTarFile}`);
}
if (rmSync) {
rmSync(imageTarFile, { force: true });
}
} else {
const client = await getConnection({}, registry);
Expand Down Expand Up @@ -1028,9 +1026,8 @@ export const exportImage = async (fullImageName) => {
tempDir,
allLayersExplodedDir,
);
} else {
console.log(`Unable to export image to ${tempDir}`);
}
console.log(`Unable to export image to ${tempDir}`);
return undefined;
};

Expand Down
11 changes: 5 additions & 6 deletions envcontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,10 @@ const getCommandOutput = (cmd, dir, args) => {
});
if (result.status !== 0 || result.error) {
return undefined;
} else {
const stdout = result.stdout;
if (stdout) {
const cmdOutput = Buffer.from(stdout).toString();
return cmdOutput.trim();
}
}
const stdout = result.stdout;
if (stdout) {
const cmdOutput = Buffer.from(stdout).toString();
return cmdOutput.trim();
}
};
Loading
Loading