New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@darkobits/chex

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkobits/chex - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

dist/index.d.ts

@@ -1,1 +0,1 @@

export { default, type ExecaWrapper } from "./lib/chex";
export { default, type ExecaWrapper } from './lib/chex';
import { execa, execaCommand, execaCommandSync, execaSync } from "execa";
import semver from "semver";
import getExecutableVersion from "./get-executable-version.js";
function parseDependencyExpression(versionExpression) {
const [rawName, versionRange] = versionExpression.split(' ');
const name = rawName.toLowerCase();
if (versionRange) {

@@ -16,6 +14,4 @@ if (semver.validRange(versionRange)) {

}
throw new Error(`Invalid semver range: ${versionRange}`);
}
return {

@@ -26,3 +22,2 @@ name,

}
function chexCommon(name, versionRange, version, rawVersion) {

@@ -32,11 +27,8 @@ if (versionRange && version === 'unknown') {

}
if (versionRange && !semver.valid(version)) {
throw new Error(`Version "${version}" of "${name}" is not a valid semver version.`);
}
if (versionRange && !semver.satisfies(version, versionRange)) {
throw new Error(`Version "${version}" of "${name}" does not satisfy criteria "${versionRange}".`);
}
const execaWrapper = (commandStringOrArgumentsArray, execaOpts) => {

@@ -46,6 +38,4 @@ if (typeof commandStringOrArgumentsArray === 'string') {

}
return execa(name, commandStringOrArgumentsArray, execaOpts);
};
execaWrapper.sync = (commandStringOrArgumentsArray, execaOpts) => {

@@ -55,6 +45,4 @@ if (typeof commandStringOrArgumentsArray === 'string') {

}
return execaSync(name, commandStringOrArgumentsArray, execaOpts);
};
execaWrapper.version = version;

@@ -64,3 +52,2 @@ execaWrapper.rawVersion = rawVersion;

}
const chex = async (dependencyExpression, execaOpts) => {

@@ -77,3 +64,2 @@ const {

};
chex.sync = (dependencyExpression, execaOpts) => {

@@ -90,4 +76,3 @@ const {

};
export default chex;
//# sourceMappingURL=chex.js.map

@@ -9,17 +9,12 @@ import { execa, execaSync } from "execa";

};
function normalizeName(name) {
return name.toLocaleLowerCase();
}
function parseVersionResult(result) {
for (const stream of ['stdout', 'stderr']) {
const rawVersion = result[stream];
if (!rawVersion) {
continue;
}
const strictVersion = findVersions(rawVersion)[0];
if (strictVersion) {

@@ -31,3 +26,2 @@ return {

}
const looseVersion = semver.clean(findVersions(rawVersion, {

@@ -38,3 +32,2 @@ loose: true

});
if (looseVersion) {

@@ -48,3 +41,2 @@ return {

}
function handleError(name, err) {

@@ -55,3 +47,2 @@ if (err && err.errno === 'ENOENT') {

}
async function getExecutableVersion(name, execaOpts) {

@@ -61,3 +52,2 @@ for (const flag of versionFlags) {

const version = parseVersionResult(await execa(normalizeName(name), [flag], execaOpts));
if (version) {

@@ -70,6 +60,4 @@ return version;

}
return unknownVersionResult;
}
getExecutableVersion.sync = (name, execaOpts) => {

@@ -79,3 +67,2 @@ for (const flag of versionFlags) {

const version = parseVersionResult(execaSync(normalizeName(name), [flag], execaOpts));
if (version) {

@@ -88,7 +75,5 @@ return version;

}
return unknownVersionResult;
};
export default getExecutableVersion;
//# sourceMappingURL=get-executable-version.js.map
{
"name": "@darkobits/chex",
"version": "2.0.2",
"version": "2.0.3",
"description": "Check that an executable is installed and verify its version.",

@@ -10,3 +10,3 @@ "author": "darkobits",

"type": "git",
"url": "git+https://github.com/darkobits/chex.git"
"url": "https://github.com/darkobits/chex.git"
},

@@ -23,11 +23,11 @@ "files": [

"find-versions": "^5.1.0",
"semver": "^7.3.7"
"semver": "^7.3.8"
},
"devDependencies": {
"@darkobits/eslint-plugin": "^0.2.9",
"@darkobits/ts": "^0.12.4",
"@types/semver": "^7.3.12",
"@types/uuid": "^8.3.4",
"uuid": "^8.3.2"
"@darkobits/ts": "^0.13.0-beta.0",
"@types/semver": "^7.3.13",
"@types/uuid": "^9.0.0",
"uuid": "^9.0.0"
}
}

@@ -6,3 +6,3 @@ <a href="#top" id="top">

<a href="https://www.npmjs.com/package/@darkobits/chex"><img src="https://img.shields.io/npm/v/@darkobits/chex.svg?style=flat-square"></a>
<a href="https://github.com/darkobits/chex/actions?query=workflow%3Aci"><img src="https://img.shields.io/github/workflow/status/darkobits/chex/ci/master?style=flat-square"></a>
<a href="https://github.com/darkobits/chex/actions?query=workflow%3Aci"><img src="https://img.shields.io/github/actions/workflow/status/darkobits/chex/ci.yml?style=flat-square"></a>
<a href="https://app.codecov.io/gh/darkobits/chex/branch/master"><img src="https://img.shields.io/codecov/c/github/darkobits/chex/master?style=flat-square"></a>

@@ -13,4 +13,4 @@ <a href="https://depfu.com/github/darkobits/chex"><img src="https://img.shields.io/depfu/darkobits/chex?style=flat-square"></a>

If you use [Execa](https://github.com/sindresorhus/execa) in your application to
integrate with other executables, this tool provides a way to:
If you use [Execa](https://github.com/sindresorhus/execa) in your application to integrate with other
executables, this tool provides a way to:

@@ -28,14 +28,12 @@ 1. Verify that an executable is installed and fail fast if is isn't and/or:

Chex exports an async function that accepts a string. That string may be an
executable name, or an executable name and [valid semver range](https://devhints.io/semver).
If a name alone is provided, Chex makes sure the executable is installed. If a
semver range is provided along with a name, Chex ensures that the version of the
executable satisfies that semver range. Chex then returns an Execa decorator
Chex exports an async function that accepts a string. That string may be an executable name, or an
executable name and [valid semver range](https://devhints.io/semver). If a name alone is provided, Chex
makes sure the executable is installed. If a semver range is provided along with a name, Chex ensures
that the version of the executable satisfies that semver range. Chex then returns an Execa decorator
bound to the provided executable.
Let's imagine we are writing a tool that is going to make several calls to the
`git` CLI, and we know that we need Git version 2.0.0 or greater. We want to
make this assertion as early as possible in our program so we can present the
user with a meaningful error before we try to use an unsupported Git feature.
Let's see how we can accomplish this with Chex:
Let's imagine we are writing a tool that is going to make several calls to the `git` CLI, and we know
that we need Git version 2.0.0 or greater. We want to make this assertion as early as possible in our
program so we can present the user with a meaningful error before we try to use an unsupported Git
feature. Let's see how we can accomplish this with Chex:

@@ -57,3 +55,3 @@ ```ts

// Execa options are passed-though to Execa:
const pushResult = await git('push origin master', {stdio: 'inherit'});
const pushResult = await git('push origin master', { stdio: 'inherit' });

@@ -83,4 +81,4 @@ // You can also do all of the above synchronously:

Chex will also attach `version` and `rawVersion` properties to the value it
returns, which you can use for debugging/reporting:
Chex will also attach `version` and `rawVersion` properties to the value it returns, which you can use
for debugging/reporting:

@@ -103,7 +101,5 @@ ```ts

Chex is available in asynchronous and synchronous modes. This package's default
export is the asynchronous function. The synchronous function is available at
the `.sync` property.
Chex is available in asynchronous and synchronous modes. This package's default export is the
asynchronous function. The synchronous function is available at the `.sync` property.
```ts

@@ -116,6 +112,5 @@ interface Chex {

**Note:** Execa options provided to `chex` or `chex.sync` will be used to
configure the call to locate the executable. Calls to the executable itself may
be configured by providing an Execa options object to the wrapper returned by
Chex.
**Note:** Execa options provided to `chex` or `chex.sync` will be used to configure the call to locate
the executable. Calls to the executable itself may be configured by providing an Execa options object to
the wrapper returned by Chex.

@@ -148,19 +143,16 @@ `ExecaWrapper` is a function with the following signature and properties:

**Note:** Both the synchronous and asynchronous versions of Chex return the
same Execa wrapper, which itself has synchronous and asynchronous modes. It is
therefore possible to mix and match these call types to fit your application's
needs.
**Note:** Both the synchronous and asynchronous versions of Chex return the same Execa wrapper, which
itself has synchronous and asynchronous modes. It is therefore possible to mix and match these call
types to fit your application's needs.
## Caveats
Some tools make the process of determining their version exceedingly difficult.
If Chex is unable to determine the version of an executable _and_ you provided a
semver range, Chex will throw an error because it is unable to guarantee that
the version of the executable satisfies your criteria. For these executables,
you can omit a version criteria and Chex will still throw if the executable is
not found.
Some tools make the process of determining their version exceedingly difficult. If Chex is unable to
determine the version of an executable _and_ you provided a semver range, Chex will throw an error
because it is unable to guarantee that the version of the executable satisfies your criteria. For these
executables, you can omit a version criteria and Chex will still throw if the executable is not found.
<br />
<a href="#top">
<img src="https://user-images.githubusercontent.com/441546/102322726-5e6d4200-3f34-11eb-89f2-c31624ab7488.png" style="max-width: 100%;">
<img src="https://user-images.githubusercontent.com/441546/189774318-67cf3578-f4b4-4dcc-ab5a-c8210fbb6838.png" style="max-width: 100%;">
</a>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc