Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { platform } from 'process'
import { normalize } from 'path'
import test from 'ava'
import { each } from 'test-each'
import { getBinPathSync } from 'get-bin-path'
import execa from 'execa'
import isCi from 'is-ci'
import pathKey from 'path-key'
import nvexeca from '../src/main.js'
import { HELPER_VERSION, TEST_VERSION } from './helpers/versions.js'
const FORK_FILE = normalize(`${__dirname}/helpers/fork.js`)
const BIN_PATH = getBinPathSync()
// Those tests do not work in Travis CI with Windows.
// However they work on Windows locally.
// TODO: figure out why those tests are failing on CI.
// This will probably be fixed once nyc@15 is released.
// See https://github.com/istanbuljs/spawn-wrap/issues/108
if (platform !== 'win32' || !isCi) {
each(
[
['node', '--version'],
['node', FORK_FILE, 'node', '--version'],
['node', BIN_PATH, HELPER_VERSION, 'node', '--version'],
],
[{}, { [pathKey()]: undefined }],
({ title }, args, env) => {
test(`Works with child processes | ${title}`, async t => {
import { execFile } from 'child_process'
import { promisify } from 'util'
import { getBinPathSync } from 'get-bin-path'
const NVE_PATH = getBinPathSync()
const pExecFile = promisify(execFile)
const VERSION = '6.0.0'
// This must be substracted from the time taken by any of the following tasks
export const nodeVersion = {
title: 'node --version',
async main() {
await pExecFile('node', ['--version'])
},
}
// This must be substracted from the time taken by nvm
export const bash = async function() {
await pExecFile('bash', ['-i', '-c', ''])