Skip to content

Commit a543b9f

Browse files
jamestalmagesindresorhus
authored andcommitted
revert npm link fix. (#859)
This mostly reverts #815, and #827. The Node regressions they fixed were resolved in Node 6.2.0. The new behavior is just to print a warning message so people know how to fix it.
1 parent 0ef6dc4 commit a543b9f

File tree

1 file changed

+12
-49
lines changed

1 file changed

+12
-49
lines changed

Diff for: lib/fork.js

+12-49
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ var debug = require('debug')('ava');
88
var AvaError = require('./ava-error');
99
var doSend = require('./send');
1010

11-
var fixNpmLink = fs.realpathSync(__filename) !== __filename;
12-
13-
if (fixNpmLink) {
14-
// Workaround for breakage caused by https://github.com/nodejs/node/pull/5950
15-
// Those changes will be reverted in https://github.com/nodejs/node/pull/6537
16-
17-
// Revert #815 and #827 when the above changes land in Node.js
18-
console.warn('WARNING: `npm link ava` detected: This breaks NYC coverage on early versions of Node 6.\nSee https://github.com/avajs/ava/pull/815');
11+
if (fs.realpathSync(__filename) !== __filename) {
12+
console.warn(
13+
'WARNING: `npm link ava` and the `--preserve-symlink` flag are incompatible. ' +
14+
'We have detected that AVA is linked via `npm link`, and that your are using either using ether ' +
15+
'an early version of Node 6, or the `--preserve-symlink` flag. This breaks AVA. ' +
16+
'You should upgrade to Node 6.2.0+, avoid the `--preserve-symlink` flag, or avoid using `npm link ava`.'
17+
);
1918
}
2019

2120
var env = process.env;
@@ -42,47 +41,11 @@ module.exports = function (file, opts) {
4241
} : false
4342
}, opts);
4443

45-
var ps;
46-
47-
if (fixNpmLink) {
48-
// Workaround for breakage caused by https://github.com/nodejs/node/pull/5950
49-
// Those changes will be reverted in https://github.com/nodejs/node/pull/6537
50-
51-
// Revert #815 and #827 when the above changes land in Node.js
52-
var execArgv = process.execArgv;
53-
var cwd = path.dirname(file);
54-
55-
// This whole if statement is copied straight out of Nodes `child_process`
56-
if (process._eval != null) { // eslint-disable-line
57-
var index = execArgv.lastIndexOf(process._eval);
58-
if (index > 0) {
59-
// Remove the -e switch to avoid fork bombing ourselves.
60-
execArgv = execArgv.slice();
61-
execArgv.splice(index - 1, 2);
62-
}
63-
}
64-
65-
var testWorkerPath = path.join(__dirname, 'test-worker.js');
66-
67-
var args = execArgv.concat([
68-
'-e',
69-
'require(' + JSON.stringify(testWorkerPath) + ')',
70-
testWorkerPath,
71-
JSON.stringify(opts)
72-
]);
73-
74-
ps = childProcess.spawn(process.execPath, args, {
75-
cwd: cwd,
76-
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
77-
env: env
78-
});
79-
} else {
80-
ps = childProcess.fork(path.join(__dirname, 'test-worker.js'), [JSON.stringify(opts)], {
81-
cwd: path.dirname(file),
82-
silent: true,
83-
env: env
84-
});
85-
}
44+
var ps = childProcess.fork(path.join(__dirname, 'test-worker.js'), [JSON.stringify(opts)], {
45+
cwd: path.dirname(file),
46+
silent: true,
47+
env: env
48+
});
8649

8750
var relFile = path.relative('.', file);
8851

0 commit comments

Comments
 (0)