fix: bump deps and fix tests for local dev (#1139)

Upgraded tests for node 8
This commit is contained in:
Remy Sharp
2017-12-04 14:56:44 +00:00
committed by GitHub
parent 5a89df6471
commit 6d57dac0ee
9 changed files with 2811 additions and 5462 deletions

2
.gitignore vendored
View File

@@ -7,6 +7,8 @@ lib-cov
*.pid
*.gz
.vscode/
pids
logs
results

View File

@@ -6,12 +6,10 @@ language: node_js
notifications:
email: false
node_js:
- 9
- 8
- 7
- 6
- 4
before_install:
- npm i -g npm@^2.0.0
before_script:
- npm prune
- 'curl -Lo travis_after_all.py https://git.io/vLSON'

View File

@@ -87,8 +87,8 @@ function rulesToMonitor(watch, ignore, config) {
// if the url ends with * but not **/* and not *.*
// then convert to **/* - somehow it was missed :-\
if (rule.slice(-4) !== '**/*' &&
rule.slice(-1) === '*' &&
rule.indexOf('*.') === -1) {
rule.slice(-1) === '*' &&
rule.indexOf('*.') === -1) {
rule += '*/*';
}
@@ -119,7 +119,7 @@ function tryBaseDir(dir) {
if (stat.isFile() || stat.isDirectory()) {
return dir;
}
} catch (e) {}
} catch (e) { }
}
return false;

View File

@@ -17,7 +17,7 @@ var debouncedBus;
bus.on('reset', resetWatchers);
function resetWatchers() {
debug('resetting watchers');
debugRoot('resetting watchers');
watchers.forEach(function (watcher) {
watcher.close();
});
@@ -49,12 +49,18 @@ function watch() {
ignored = [ignored, dotFilePattern];
}
var watcher = chokidar.watch(dir, {
var watchOptions = {
ignored: ignored,
persistent: true,
usePolling: config.options.legacyWatch || false,
interval: config.options.pollingInterval,
});
};
if (process.env.TEST) {
watchOptions.useFsEvents = false;
}
var watcher = chokidar.watch(dir, watchOptions);
watcher.ready = false;

8162
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,9 @@
"lint": "jscs lib/**/*.js -v",
":spec": "node_modules/.bin/mocha --timeout 30000 --ui bdd test/**/*.test.js",
"test": "npm run lint && npm run spec",
"spec": "for FILE in test/**/*.test.js; do echo $FILE; ./node_modules/.bin/mocha --timeout 30000 $FILE; if [ $? -ne 0 ]; then exit 1; fi; sleep 1; done",
"spec": "for FILE in test/**/*.test.js; do echo $FILE; TEST=1 mocha --timeout 30000 $FILE; if [ $? -ne 0 ]; then exit 1; fi; sleep 1; done",
"postspec": "npm run clean",
"clean": "rm -rf test/fixtures/test*.js",
"web": "node web",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
@@ -41,7 +43,6 @@
"@commitlint/config-angular": "^3.1.1",
"async": "1.4.2",
"coffee-script": "~1.7.1",
"connect": "~2.19.1",
"husky": "^0.14.3",
"istanbul": "~0.2.10",
"jscs": "2.1.1",

View File

@@ -29,13 +29,12 @@ describe('listeners clean up', function () {
it('should be able to re-run in required mode, many times, and not leak' +
'listeners', function (done) {
function run() {
function run(n) {
return function (done) {
nodemon(conf());
nodemon.on('start', function () {
nodemon.on('exit', function () {
nodemon.reset(done);
// done(null, id);
});
});
};
@@ -49,4 +48,4 @@ describe('listeners clean up', function () {
async.series(toRun);
});
});
});

View File

@@ -1,27 +1,27 @@
'use strict';
/*global describe:true, it: true, after: true */
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
utils = require('../utils'),
appjs = utils.appjs,
cleanup = utils.cleanup,
run = utils.run,
files = [],
randomFile = function () {
return '_nodemon' + (Math.random() * Date.now() | 0);
};
path = require('path'),
fs = require('fs'),
utils = require('../utils'),
appjs = utils.appjs,
cleanup = utils.cleanup,
run = utils.run,
files = [],
randomFile = function () {
return '_nodemon' + (Math.random() * Date.now() | 0);
};
function ignore(rule, done, file) {
var p = run((rule ? ('-i ' + rule + ' ') : '') + appjs, {
output: function (data) {
// console.log(data.trim());
},
error: function (data) {
p.send('quit');
cleanup(p, done, new Error(data));
},
});
output: function (data) {
// console.log(data.trim());
},
error: function (data) {
p.send('quit');
cleanup(p, done, new Error(data));
},
});
p.on('message', function (event) {
if (event.type === 'start') {
@@ -32,7 +32,7 @@ function ignore(rule, done, file) {
}
files.push(file);
fs.writeFile(file, function (err) {
fs.writeFile(file, '', function (err) {
if (err) {
console.log('error on writing file');
cleanup(p, done, new Error(err));
@@ -41,7 +41,6 @@ function ignore(rule, done, file) {
// if this fires, then *nothing* happened, which is good
setTimeout(function () {
// assert(true, 'nodemon did not restart');
cleanup(p, done);
}, 1000);
}, 1000);
@@ -55,7 +54,7 @@ function ignore(rule, done, file) {
describe('nodemon ignore', function () {
after(function (done) {
files.forEach(function (file) {
fs.unlink(file, function () {});
fs.unlink(file, function () { });
});
done();
});
@@ -65,7 +64,7 @@ describe('nodemon ignore', function () {
});
it('should ignore node_modules by default', function (done) {
ignore(null, done, path.join(process.cwd(), 'node_modules', 'connect', 'node_modules', randomFile()));
ignore(null, done, path.join(process.cwd(), 'node_modules', 'mocha', 'node_modules', randomFile()));
});
});

View File

@@ -15,7 +15,7 @@ describe('when nodemon runs (2)', function () {
var tmp = path.resolve('test/fixtures/test' + rnd() + '.js');
after(function (done) {
fs.unlink(tmp);
fs.unlink(tmp, function () { });
// clean up just in case.
nodemon.once('exit', function () {
nodemon.reset();
@@ -28,14 +28,14 @@ describe('when nodemon runs (2)', function () {
});
it('should restart when new files are added', function (done) {
fs.writeFileSync(tmp, 'setTimeout(true, 10000)');
fs.writeFileSync(tmp, 'setTimeout(function(){}, 10000)');
var tmp2 = path.resolve('test/fixtures/test' + rnd() + '-added.js');
nodemon({
script: tmp,
}).on('start', function () {
setTimeout(function () {
fs.writeFileSync(tmp2, 'setTimeout(true, 10000)');
fs.writeFileSync(tmp2, 'setTimeout(function(){}, 10000)');
}, 500);
}).on('restart', function () {
assert(true, 'restarted after new file was added');
@@ -136,23 +136,23 @@ describe('when nodemon runs (2)', function () {
it('should not run command on startup if runOnChangeOnly is true',
function (done) {
fs.writeFileSync(tmp, 'console.log("testing 1 2 3")');
fs.writeFileSync(tmp, 'console.log("testing 1 2 3")');
nodemon({
script: tmp,
runOnChangeOnly: true,
stdout: false,
}).on('start', function () {
assert(false, 'script should not start');
}).once('exit', function () {
done();
nodemon({
script: tmp,
runOnChangeOnly: true,
stdout: false,
}).on('start', function () {
assert(false, 'script should not start');
}).once('exit', function () {
done();
});
setTimeout(function () {
nodemon.emit('quit');
}, 1500);
});
setTimeout(function () {
nodemon.emit('quit');
}, 1500);
});
// it('should kill child on SIGINT', function (done) {
// fs.writeFileSync(tmp, 'setTimeout(function () { var n = 10; }, 10000)');