Skip to content

Commit

Permalink
Use latest nve release
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Oct 20, 2019
1 parent 37fa6bb commit 52eb452
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"test": "test"
},
"dependencies": {
"async-iterator-all": "^1.0.0",
"bytes": "^3.1.0",
"chalk": "^3.0.0-beta.2",
"cli-cursor": "^3.1.0",
Expand Down
8 changes: 4 additions & 4 deletions src/run/runners/node/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export const commands = async function(runOpts) {
const getNodeCommand = function({
command,
spawnOptions,
versionRange,
version,
fullVersion,
}) {
const versions = version === fullVersion ? [] : [{ value: fullVersion }]
const versions = versionRange === version ? [] : [{ value: version }]
return {
id: version,
title: version,
id: versionRange,
title: versionRange,
spawn: [command, START_PATH],
spawnOptions,
versions,
Expand Down
31 changes: 13 additions & 18 deletions src/run/runners/node/versions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { runVersion } from 'nve'
import { runVersions } from 'nve'
import { satisfies } from 'semver'
import readPkgUp from 'read-pkg-up'
import asyncIteratorAll from 'async-iterator-all'

// Normalize the node `versions` option
export const getNodeVersions = async function({ versions }) {
Expand All @@ -24,21 +25,15 @@ const SEPARATOR_REGEXP = /\s*,\s*/u

// We retrieve the full Node versions for validation purpose and for `--info`,
// but not for the command id/title
const getFullVersions = function(versions) {
return Promise.all(versions.map(getFullVersion))
}

// This both downloads Node.js binary and normalize its `version`.
// This also retrieves the `command` and `spawnOptions`.
const getFullVersion = async function(version) {
const getFullVersions = async function(versions) {
try {
const { version: fullVersion, command, spawnOptions } = await runVersion(
version,
'node',
['--version'],
{ progress: true },
)
return { version, fullVersion, command, spawnOptions }
const iterable = await runVersions(versions, 'node', ['--version'], {
progress: true,
})
const versionsA = await asyncIteratorAll(iterable)
return versionsA
} catch (error) {
// eslint-disable-next-line fp/no-mutation
error.message = `In option 'run.node.versions': ${error.message}`
Expand All @@ -58,15 +53,15 @@ const getAllowedVersions = async function() {

// We validate the versions before starting the benchmarks.
const validateVersions = function(versions, allowedVersions) {
versions.forEach(({ version, fullVersion }) =>
validateVersion(version, fullVersion, allowedVersions),
versions.forEach(({ versionRange, version }) =>
validateVersion(versionRange, version, allowedVersions),
)
}

const validateVersion = function(version, fullVersion, allowedVersions) {
if (!satisfies(fullVersion, allowedVersions)) {
const validateVersion = function(versionRange, version, allowedVersions) {
if (!satisfies(version, allowedVersions)) {
throw new Error(
`In option 'run.node.versions': version ${version} must be ${allowedVersions}`,
`In option 'run.node.versions': version ${versionRange} must be ${allowedVersions}`,
)
}
}

0 comments on commit 52eb452

Please sign in to comment.