mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
refactor: small tweaks to ES6-ish
This commit is contained in:
12
doc/rules.md
12
doc/rules.md
@@ -12,23 +12,23 @@ Given a nodemon.json file that contains:
|
||||
Then nodemon detects changes, but what causes nodemon to restart? The ignored files or the watched files? Which wins?
|
||||
|
||||
```js
|
||||
var files = ['server/foo.coffee', 'server/app.js'];
|
||||
const files = ['server/foo.coffee', 'server/app.js'];
|
||||
|
||||
// afterIgnore = ['server/app.js'] now since foo.coffee matches *.coffee
|
||||
var afterIgnore = files.filter(applyIgnore);
|
||||
const afterIgnore = files.filter(applyIgnore);
|
||||
|
||||
// watch = ['server/foo.coffee'] as it's under the watch
|
||||
var watched = files.filter(applyWatch);
|
||||
const watched = files.filter(applyWatch);
|
||||
```
|
||||
|
||||
What about:
|
||||
|
||||
```js
|
||||
var files = ['test/app.js', 'test/app.coffee'];
|
||||
const files = ['test/app.js', 'test/app.coffee'];
|
||||
|
||||
// afterIgnore = ['test/app.js'] now since test/app.coffee matches *.coffee
|
||||
var afterIgnore = files.filter(applyIgnore);
|
||||
const afterIgnore = files.filter(applyIgnore);
|
||||
|
||||
// watch.length = 2 as watch implies test/*.*
|
||||
var watched = files.filter(applyWatch);
|
||||
const watched = files.filter(applyWatch);
|
||||
```
|
||||
|
||||
6
faq.md
6
faq.md
@@ -38,7 +38,7 @@ nodemon -x 'mocha test/bad.test.js || exit 1'
|
||||
|
||||
# Can't install nodemon: permission issue
|
||||
|
||||
You may need to install nodemon using `sudo` (which isn't recommended, but I understand it's unavoidable in some environemnts). If the install fails with this appearing in the npm error log, then you need the following workaround.
|
||||
You may need to install nodemon using `sudo` (which isn't recommended, but I understand it's unavoidable in some environments). If the install fails with this appearing in the npm error log, then you need the following workaround.
|
||||
|
||||
```
|
||||
gyp WARN EACCES user "root" does not have permission to access the dev dir "<some-local-dir>"
|
||||
@@ -198,9 +198,9 @@ For example, on `lib/app.js` being changed:
|
||||
|
||||
## My .nodemonignore is being ignored
|
||||
|
||||
The new `nodemon.json` superceeds the `.nodemonignore` file, so if you have both, the `.nodemonignore` is not used at all.
|
||||
The new `nodemon.json` supersedes the `.nodemonignore` file, so if you have both, the `.nodemonignore` is not used at all.
|
||||
|
||||
Note that if you have a `nodemon.json` in your `$HOME` path, then this will also supersede the old ignore file.
|
||||
Note that if you have a `nodemon.json` in your `$HOME` path, then this will also supersede the old ignore file (and the _legacy_ format config is ignored).
|
||||
|
||||
## nodemon does nothing
|
||||
|
||||
|
||||
@@ -202,16 +202,13 @@ function loadFile(options, config, dir, ready) {
|
||||
|
||||
function loadPackageJSON(config, ready) {
|
||||
if (!ready) {
|
||||
ready = function () { };
|
||||
ready = () => {};
|
||||
}
|
||||
|
||||
var dir = process.cwd();
|
||||
var filename = path.join(dir, 'package.json');
|
||||
var packageLoadOptions = { configFile: filename };
|
||||
return loadFile(packageLoadOptions, config, dir, function (settings) {
|
||||
if (settings.nodemonConfig) {
|
||||
utils.log.detail('using config in package.json');
|
||||
}
|
||||
const dir = process.cwd();
|
||||
const filename = path.join(dir, 'package.json');
|
||||
const packageLoadOptions = { configFile: filename };
|
||||
return loadFile(packageLoadOptions, config, dir, settings => {
|
||||
ready(settings.nodemonConfig || {});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,12 +81,14 @@ function nodemon(settings) {
|
||||
// always echo out the current version
|
||||
utils.log.info(version.pinned);
|
||||
|
||||
const cwd = process.cwd();
|
||||
|
||||
if (config.options.cwd) {
|
||||
utils.log.detail('process root: ' + process.cwd());
|
||||
utils.log.detail('process root: ' + cwd);
|
||||
}
|
||||
|
||||
config.loaded.forEach(function (filename) {
|
||||
utils.log.detail('reading config ' + filename);
|
||||
config.loaded.map(file => file.replace(cwd, '.')).forEach(file => {
|
||||
utils.log.detail('reading config ' + file);
|
||||
});
|
||||
|
||||
// echo out notices about running state
|
||||
|
||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -283,12 +283,6 @@
|
||||
"integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=",
|
||||
"dev": true
|
||||
},
|
||||
"assert-plus": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
|
||||
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=",
|
||||
"dev": true
|
||||
},
|
||||
"async": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-1.4.2.tgz",
|
||||
@@ -2593,6 +2587,14 @@
|
||||
"assert-plus": "0.2.0",
|
||||
"jsprim": "1.4.1",
|
||||
"sshpk": "1.13.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
|
||||
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"https-proxy-agent": {
|
||||
|
||||
83
test/config/load-logging.test.js
Normal file
83
test/config/load-logging.test.js
Normal file
@@ -0,0 +1,83 @@
|
||||
'use strict';
|
||||
/*global describe, it, afterEach, beforeEach, after */
|
||||
const load = require('../../lib/config/load');
|
||||
const utils = require('../../lib/utils')
|
||||
const path = require('path');
|
||||
const testUtils = require('../utils');
|
||||
const assert = require('assert');
|
||||
const noop = {};
|
||||
|
||||
describe('config logging', () => {
|
||||
const pwd = process.cwd();
|
||||
const oldHome = utils.home;
|
||||
|
||||
beforeEach(() => {
|
||||
// move to the fixtures directory to allow for config loading
|
||||
process.chdir(path.resolve(pwd, 'test/fixtures'));
|
||||
utils.home = path.resolve(pwd, ['test', 'fixtures', 'global'].join(path.sep));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.chdir(pwd);
|
||||
utils.home = oldHome;
|
||||
});
|
||||
|
||||
it('should show package is being used', done => {
|
||||
process.chdir(path.resolve(pwd, 'test/fixtures/packages/package-json-settings'));
|
||||
const config = {};
|
||||
|
||||
load(noop, noop, config, () => {
|
||||
assert.equal(config.loaded.length, 2, 'global nodemon and local package');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not read package if no nodemonConfig', done => {
|
||||
utils.home = process.cwd();
|
||||
process.chdir(path.resolve(pwd, 'test/fixtures'));
|
||||
const config = {};
|
||||
|
||||
load(noop, noop, config, () => {
|
||||
const files = config.loaded.map(_ => path.relative(pwd, _));
|
||||
assert.equal(files.length, 1, 'global nodemon');
|
||||
assert.deepEqual(files, ['test/fixtures/nodemon.json'], 'global nodemon');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should ignore legacy if new format is found', done => {
|
||||
utils.home = process.cwd();
|
||||
process.chdir(path.resolve(pwd, 'test/fixtures/legacy'));
|
||||
const config = {};
|
||||
|
||||
load(noop, noop, config, () => {
|
||||
const loaded = config.loaded.map(_ => path.relative(pwd, _));
|
||||
assert.equal(loaded.length, 1, 'global nodemon is loaded and legacy is ignored');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should load legacy if no nodemon.json found', done => {
|
||||
utils.home = path.resolve(pwd, 'test/fixtures/configs'); // no valid nodemon.json files
|
||||
process.chdir(path.resolve(pwd, 'test/fixtures/legacy'));
|
||||
const config = {};
|
||||
|
||||
load(noop, noop, config, () => {
|
||||
const loaded = config.loaded.map(_ => path.relative(pwd, _));
|
||||
assert.equal(loaded.length, 1, 'legacy loaded');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should load nothing if nothing found', done => {
|
||||
utils.home = path.resolve(pwd, 'test/fixtures/configs'); // no valid nodemon.json files
|
||||
process.chdir(pwd);
|
||||
const config = {};
|
||||
|
||||
load(noop, noop, config, () => {
|
||||
const loaded = config.loaded.map(_ => path.relative(pwd, _));
|
||||
assert.deepEqual(loaded, [], 'nothing loaded');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user