From 69dbcf23c3ae6f80a2c3a7c926a1e185e7f2f31e Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 16 Feb 2016 18:07:32 +0700 Subject: [PATCH] cleanup #531 --- lib/fork.js | 5 ++--- test/cli.js | 3 ++- test/fixture/node-paths.js | 5 ++--- test/fixture/node-paths/deep/nested/path/bar.js | 5 +---- test/fixture/node-paths/modules/nested/foo.js | 5 +---- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/fork.js b/lib/fork.js index 3affd0795..99fe2be6b 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -9,6 +9,7 @@ var send = require('./send'); var env = process.env; +// ensure NODE_PATH paths are absolute if (process.env.NODE_PATH) { var nodePath = process.env.NODE_PATH .split(path.delimiter) @@ -17,9 +18,7 @@ if (process.env.NODE_PATH) { }) .join(path.delimiter); - env = objectAssign({ - NODE_PATH: nodePath - }, env); + env = objectAssign({NODE_PATH: nodePath}, env); } module.exports = function (file, opts) { diff --git a/test/cli.js b/test/cli.js index 555f8b0c7..426dec5b4 100644 --- a/test/cli.js +++ b/test/cli.js @@ -161,8 +161,9 @@ test('watcher works', function (t) { test('handles NODE_PATH', function (t) { var nodePaths = 'node-paths/modules' + path.delimiter + 'node-paths/deep/nested'; + execCli('fixture/node-paths.js', {env: {NODE_PATH: nodePaths}}, function (err) { - t.notOk(err); + t.ifError(err); t.end(); }); }); diff --git a/test/fixture/node-paths.js b/test/fixture/node-paths.js index a199611e7..192858d9c 100644 --- a/test/fixture/node-paths.js +++ b/test/fixture/node-paths.js @@ -1,9 +1,8 @@ import test from '../../'; - import foo from 'nested/foo'; import bar from 'path/bar'; test('relative require', t => { - t.is(foo(), 'bar'); - t.is(bar(), 'baz'); + t.is(foo, 'bar'); + t.is(bar, 'baz'); }); diff --git a/test/fixture/node-paths/deep/nested/path/bar.js b/test/fixture/node-paths/deep/nested/path/bar.js index 9642d6cc4..f24e54fd0 100644 --- a/test/fixture/node-paths/deep/nested/path/bar.js +++ b/test/fixture/node-paths/deep/nested/path/bar.js @@ -1,4 +1 @@ -module.exports = function () { - return 'baz'; -}; - +module.exports = 'baz'; diff --git a/test/fixture/node-paths/modules/nested/foo.js b/test/fixture/node-paths/modules/nested/foo.js index a695c3b37..cb1c2c01e 100644 --- a/test/fixture/node-paths/modules/nested/foo.js +++ b/test/fixture/node-paths/modules/nested/foo.js @@ -1,4 +1 @@ -module.exports = function () { - return 'bar'; -}; - +module.exports = 'bar';