Skip to content

Commit

Permalink
Replace forEach with for of loops
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ committed Jul 16, 2024
1 parent 7a08ef4 commit ecab212
Show file tree
Hide file tree
Showing 8 changed files with 1,489 additions and 851 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules/
node_modules/
.idea/
.npm/
__types/
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 1.0.3 - 2024-07-16
* Updated dependencies
* Replaced `forEach` loops with `for of` loops for better performance

## 1.0.2 - 2021-05-05

- Downgrade semver dependency to 6.3.0 for Internet Explorer compatibility
Expand Down
14 changes: 7 additions & 7 deletions check-npm-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const compatibleVersionIsInstalled = (name: string, range: string | semver.Range
} else {
return installedVersion;
}
} catch (e) {
} catch (e: any) {
// XXX add something to the tool to make this more reliable
const message = e.toString();
// One message comes out of the install npm package the other from npm directly
if (message.includes('Cannot find module') === true || message.includes("Can't find npm module") === true) {
// One message comes out of the installation npm package the other from npm directly
if (message.includes('Cannot find module') || message.includes("Can't find npm module")) {
return false;
} else {
throw e;
Expand All @@ -39,22 +39,22 @@ export const checkNpmVersions = (packages: indexAny, packageName: string): void
if (Meteor.isDevelopment) {
const failures: indexBoolorString = {};

Object.keys(packages).forEach((name) => {
for (const name of Object.keys(packages)) {
const range = packages[name];
const failure = compatibleVersionIsInstalled(name, range);

if (failure !== true) {
failures[name] = failure;
}
});
}

if (Object.keys(failures).length === 0) {
return;
}

const errors: string[] = [];

Object.keys(failures).forEach((name) => {
for (const name of Object.keys(failures)) {
const installed = failures[name];
const requirement = `${name}@${packages[name]}`;

Expand All @@ -63,7 +63,7 @@ export const checkNpmVersions = (packages: indexAny, packageName: string): void
} else {
errors.push(` - ${name}@${packages[name]} not installed.`);
}
});
}

const qualifier = packageName ? `(for ${packageName}) ` : '';
console.warn(`WARNING: npm peer requirements ${qualifier}not installed:
Expand Down
Loading

0 comments on commit ecab212

Please sign in to comment.