Skip to content

Commit

Permalink
refactor: remove libraries over native es6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Dec 20, 2017
1 parent 35b86a9 commit 67d1466
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 60 deletions.
3 changes: 1 addition & 2 deletions bin/nodemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ nodemon(options);
var fs = require('fs');

// checks for available update and returns an instance
var defaults = require('lodash.defaults');
var pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json'));

require('update-notifier')({
pkg: defaults(pkg, { version: '0.0.0' }),
pkg: Object.assign(pkg, { version: '0.0.0' }),
}).notify();
3 changes: 1 addition & 2 deletions lib/monitor/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports.resetWatchers = resetWatchers;

var debug = require('debug')('nodemon:watch');
var debugRoot = require('debug')('nodemon');
var Promise = require('es6-promise').Promise; // jshint ignore:line
var chokidar = require('chokidar');
var undefsafe = require('undefsafe');
var config = require('../config');
Expand Down Expand Up @@ -149,7 +148,7 @@ function filterAndRestart(files) {
files.find(file => {
if (file.substr(-length, length) === script) {
matched = {
result: [ file ],
result: [file],
total: 1,
}
return true;
Expand Down
65 changes: 32 additions & 33 deletions lib/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports.pin = pin;
var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;
var Promise = require('es6-promise').Promise; // jshint ignore:line
var root = null;

function pin() {
Expand All @@ -17,39 +16,39 @@ function version(callback) {
// first find the package.json as this will be our root
var promise = findPackage(path.dirname(module.parent.filename))
.then(function (dir) {
// now try to load the package
var v = require(path.resolve(dir, 'package.json')).version;

if (v && v !== '0.0.0') {
return v;
}

root = dir;

// else we're in development, give the commit out
// get the last commit and whether the working dir is dirty
var promises = [
branch().catch(function () { return 'master'; }),
commit().catch(function () { return '<none>'; }),
dirty().catch(function () { return 0; }),
];

// use the cached result as the export
return Promise.all(promises).then(function (res) {
var branch = res[0];
var commit = res[1];
var dirtyCount = parseInt(res[2], 10);
var curr = branch + ': ' + commit;
if (dirtyCount !== 0) {
curr += ' (' + dirtyCount + ' dirty files)';
// now try to load the package
var v = require(path.resolve(dir, 'package.json')).version;

if (v && v !== '0.0.0-development') {
return v;
}

return curr;
root = dir;

// else we're in development, give the commit out
// get the last commit and whether the working dir is dirty
var promises = [
branch().catch(function () { return 'master'; }),
commit().catch(function () { return '<none>'; }),
dirty().catch(function () { return 0; }),
];

// use the cached result as the export
return Promise.all(promises).then(function (res) {
var branch = res[0];
var commit = res[1];
var dirtyCount = parseInt(res[2], 10);
var curr = branch + ': ' + commit;
if (dirtyCount !== 0) {
curr += ' (' + dirtyCount + ' dirty files)';
}

return curr;
});
}).catch(function (error) {
console.log(error.stack);
throw error;
});
}).catch(function (error) {
console.log(error.stack);
throw error;
});

if (callback) {
promise.then(function (res) {
Expand Down Expand Up @@ -97,5 +96,5 @@ function branch() {

function dirty() {
return command('expr $(git status --porcelain 2>/dev/null| ' +
'egrep "^(M| M)" | wc -l)');
}
'egrep "^(M| M)" | wc -l)');
}
39 changes: 18 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
"@remy/pstree": "^1.1.0",
"chokidar": "^1.7.0",
"debug": "^2.6.8",
"es6-promise": "^3.3.1",
"ignore-by-default": "^1.0.1",
"lodash.defaults": "^3.1.2",
"minimatch": "^3.0.4",
"touch": "^3.1.0",
"undefsafe": "0.0.3",
Expand Down

0 comments on commit 67d1466

Please sign in to comment.