Closed TiagoDanin closed 5 years ago
Problem in Travis CI: XO did not work with node V4
Can you add a test?
@sindresorhus Two problems: Sugestions?
The process.env
in test.js with import
is not loading in index.js
Required reloads the package for different tests
test.a.js (All Falid!)
import test from 'ava';
import execa from 'execa';
import globalDirs from '.';
console.log(globalDirs);
const npm = arguments => execa.stdout('npm', arguments);
test('npm.prefix with env', async t => { process.env.npm_config_PREFIX = '/usr/local/lib' t.is(globalDirs.npm.prefix, '/usr/local/lib'); }); //... all tests ...//
- test.b.js (Working "npm.prefix with env" and others falid!)
```js
const test = require('ava');
const execa = require('execa');
const npm = arguments_ => execa.stdout('npm', arguments_);
test('npm.prefix with env', async t => {
process.env.npm_config_PREFIX = '/usr/local/lib';
const globalDirs = require('.');
console.log(globalDirs);
t.is(globalDirs.npm.prefix, '/usr/local/lib');
});
//... all tests ...//
const test = require('ava');
const execa = require('execa');
const globalDirs = require('.');
console.log(globalDirs);
const npm = arguments => execa.stdout('npm', arguments);
test('npm.prefix with env', async t => { process.env.npm_config_PREFIX = '/usr/local/lib'; const globalDirsEnv = require('.'); t.is(globalDirsEnv.npm.prefix, '/usr/local/lib'); }); //... all tests ...//
@sindresorhus Done! Added new test.
I don't want to expose a .reload()
method just for testing purposes. The correct solution is to use something like https://github.com/sindresorhus/import-fresh
Fixes #4 Note: "Config values are case-insensitive" (NPM Config Docs: https://docs.npmjs.com/misc/config)