Skip to content

Commit

Permalink
chore(biome): fix useless else cases (#988)
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Setch <adam.setch@outlook.com>
  • Loading branch information
setchy committed Apr 16, 2024
1 parent a5eabfc commit 9cadc75
Show file tree
Hide file tree
Showing 5 changed files with 731 additions and 771 deletions.
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

0 comments on commit 9cadc75

Please sign in to comment.