Skip to content

Commit

Permalink
feat: performInstalledCheck()
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Mar 11, 2024
1 parent 9c5ec35 commit c437f90
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ checkVersionRange(mainPackage, key, installedDependencies, [options]) => Version

#### Arguments

* `mainPackage`: Type `NormalizedPackageJson` – the content of the `package.json` file to check
* `mainPackage`: Type `NormalizedPackageJson` – the content of the `package.json` file to check, see [`getInstalledData()`](#getinstalleddata)
* `key`: Type `string` – the key of the version range to check, eg `engines.node`
* `installedDependencies`: Type `InstalledDependencies` – the installed dependencies to use when checking
* `installedDependencies`: Type `InstalledDependencies` – the installed dependencies to use when checking, see [`getInstalledData()`](#getinstalleddata)
* `options`: Type `VersionRangeOptions` – optional options

#### Types
Expand Down Expand Up @@ -162,6 +162,10 @@ The full on `installed-check` experience, returning error and warning strings on
installedCheck(options) => Promise<InstalledCheckResult>
```
#### Arguments
* `options`: Type `InstalledCheckOptions` – needs to have at least one check – `engineCheck`, `versionCheck` – set to `true`
#### Types
```ts
Expand Down Expand Up @@ -190,3 +194,20 @@ const { errors, warnings } = await installedCheck({
versionCheck: true,
});
```

### performInstalledCheck()

Same as [`installedCheck()`](#installedcheck) but without looking up any data on its own but instead expects the data from [`getInstalledData()`](#getinstalleddata) or similar to be given to it.

#### Syntax

```ts
performInstalledCheck(mainPackage, installedDependencies, options) => Promise<InstalledCheckResult>
```

#### Arguments

* `mainPackage`: Type `NormalizedPackageJson` – the content of the `package.json` file to check, see [`getInstalledData()`](#getinstalleddata)
* `installedDependencies`: Type `InstalledDependencies` – the installed dependencies to use when checking, see [`getInstalledData()`](#getinstalleddata)
* `options`: Type `InstalledCheckOptions` – same as for [`installedCheck()`](#installedcheck), but without the `path` option

1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
export { checkVersionRange } from './lib/check-version-range.js';
export { getInstalledData } from './lib/get-installed-data.js';
export { installedCheck } from './lib/installed-check.js';
export { performInstalledCheck } from './lib/perform-installed-check.js';
4 changes: 2 additions & 2 deletions lib/installed-check.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getInstalledData } from './get-installed-data.js';
import { performInstalledChecks } from './perform-installed-checks.js';
import { performInstalledCheck } from './perform-installed-check.js';

/**
* @typedef InstalledCheckResult
Expand Down Expand Up @@ -29,5 +29,5 @@ export async function installedCheck (options) {

const { installedDependencies, mainPackage } = await getInstalledData(path);

return performInstalledChecks(mainPackage, installedDependencies, checkOptions);
return performInstalledCheck(mainPackage, installedDependencies, checkOptions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { checkPackageVersions } from './check-package-versions.js';
* @param {Omit<import('./installed-check.js').InstalledCheckOptions, 'path'>} options
* @returns {Promise<import('./installed-check.js').InstalledCheckResult>}
*/
export async function performInstalledChecks (mainPackage, installedDependencies, options) {
export async function performInstalledCheck (mainPackage, installedDependencies, options) {
if (!mainPackage) throw new TypeError('Expected mainPackage to be set');
if (!installedDependencies) throw new TypeError('Expected installedDependencies to be set');
if (!options) throw new TypeError('Expected options to be set');
Expand Down

0 comments on commit c437f90

Please sign in to comment.