Skip to content

Commit

Permalink
🐛 Remove optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
i1u5 committed Aug 12, 2020
1 parent e5780cd commit b3ac05b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions massVer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const read = (path: string): string => readFile(path, { encoding: "utf8" }),
}
});

if (missingMetadata?.length > 0)
if (missingMetadata && missingMetadata.length > 0)
console.log(
`\nThe following presence${
missingMetadata.length > 1 ? "s don't" : "doesn't"
Expand All @@ -62,7 +62,7 @@ const read = (path: string): string => readFile(path, { encoding: "utf8" }),
} else {
console.log(
`Error. ${
metadata[0].service?.length > 0
metadata[0].service && metadata[0].service.length > 0
? metadata[0].service
: metadata[1]
} does not include a valid metadata version, trying to overwrite...\n`
Expand Down
7 changes: 4 additions & 3 deletions presenceUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ const readFile = (path: string): string =>
passes: 2
}
});
if (result?.code?.length > 0) writeJS(file, result.code);
if (result && result.code && result.code.length > 0)
writeJS(file, result.code);
else {
console.error(`Error. File ${file} was not minified, skipping...`);
exitCode = 1;
Expand All @@ -88,7 +89,7 @@ const readFile = (path: string): string =>
const result = await transform(file, {
presets: [["@babel/preset-env", { exclude: ["transform-regenerator"] }]]
});
if (result?.code?.length > 0) {
if (result && result.code && result.code.length > 0) {
writeJS(file, result.code);
await minify(file);
} else {
Expand Down Expand Up @@ -262,7 +263,7 @@ const readFile = (path: string): string =>

exitCode === 0
? console.log(`✔️ ${metadata.service}`)
: metadata.service?.length > 0
: metadata.service && metadata.service.length > 0
? console.log(`❌ ${metadata.service}`)
: console.log(`❌ ${path}`);

Expand Down

0 comments on commit b3ac05b

Please sign in to comment.