Skip to content

Commit

Permalink
Export getPath
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 13, 2019
1 parent 3e95f34 commit 2ab72e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -65,6 +65,7 @@
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-shared-tasks": "^0.30.35", "gulp-shared-tasks": "^0.30.35",
"husky": "^3.0.3", "husky": "^3.0.3",
"path-exists": "^4.0.0",
"test-each": "^1.7.2" "test-each": "^1.7.2"
}, },
"engines": { "engines": {
Expand Down
11 changes: 8 additions & 3 deletions src/main.js
Expand Up @@ -10,14 +10,19 @@ import { validateInput } from './validate.js'
export const nve = async function(versionRange, args = []) { export const nve = async function(versionRange, args = []) {
validateInput(args) validateInput(args)


// Download the Node.js binary const nodePath = await getPath(versionRange)
const cacheDir = await globalCacheDir(CACHE_DIR)
const nodePath = await getNode(versionRange, cacheDir)


const { code, signal } = await runNodeProcess(nodePath, args) const { code, signal } = await runNodeProcess(nodePath, args)
return { code, signal } return { code, signal }
} }


// Download the Node.js binary
export const getPath = async function(versionRange) {
const cacheDir = await globalCacheDir(CACHE_DIR)
const nodePath = await getNode(versionRange, cacheDir)
return nodePath
}

const CACHE_DIR = 'nve' const CACHE_DIR = 'nve'


// Forward arguments to another node binary located at `nodePath`. // Forward arguments to another node binary located at `nodePath`.
Expand Down
9 changes: 8 additions & 1 deletion test/main.js
@@ -1,6 +1,7 @@
import test from 'ava' import test from 'ava'
import pathExists from 'path-exists'


import { nve } from '../src/main.js' import { nve, getPath } from '../src/main.js'


import { TEST_VERSION, runCli } from './helpers/main.js' import { TEST_VERSION, runCli } from './helpers/main.js'


Expand Down Expand Up @@ -41,3 +42,9 @@ test('Forward signal | programmatic', async t => {


t.is(signal, null) t.is(signal, null)
}) })

test('Retrieve node filepath', async t => {
const path = await getPath(TEST_VERSION)

t.true(await pathExists(path))
})

0 comments on commit 2ab72e9

Please sign in to comment.