Skip to content
Permalink
Browse files

Export `getPath`

  • Loading branch information...
ehmicky committed Aug 13, 2019
1 parent 3e95f34 commit 2ab72e97aef01a8f41347cf99fdeaac281ccc494
Showing with 17 additions and 4 deletions.
  1. +1 −0 package.json
  2. +8 −3 src/main.js
  3. +8 −1 test/main.js
@@ -65,6 +65,7 @@
"gulp": "^4.0.2",
"gulp-shared-tasks": "^0.30.35",
"husky": "^3.0.3",
"path-exists": "^4.0.0",
"test-each": "^1.7.2"
},
"engines": {
@@ -10,14 +10,19 @@ import { validateInput } from './validate.js'
export const nve = async function(versionRange, args = []) {
validateInput(args)

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

const { code, signal } = await runNodeProcess(nodePath, args)
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'

// Forward arguments to another node binary located at `nodePath`.
@@ -1,6 +1,7 @@
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'

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

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.
You can’t perform that action at this time.