aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nodemon/lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/nodemon/lib/utils')
-rw-r--r--node_modules/nodemon/lib/utils/bus.js44
-rw-r--r--node_modules/nodemon/lib/utils/clone.js40
-rw-r--r--node_modules/nodemon/lib/utils/colour.js26
-rw-r--r--node_modules/nodemon/lib/utils/index.js102
-rw-r--r--node_modules/nodemon/lib/utils/log.js82
-rw-r--r--node_modules/nodemon/lib/utils/merge.js47
6 files changed, 0 insertions, 341 deletions
diff --git a/node_modules/nodemon/lib/utils/bus.js b/node_modules/nodemon/lib/utils/bus.js
deleted file mode 100644
index 4e120c5..0000000
--- a/node_modules/nodemon/lib/utils/bus.js
+++ /dev/null
@@ -1,44 +0,0 @@
-var events = require('events');
-var debug = require('debug')('nodemon');
-var util = require('util');
-
-var Bus = function () {
- events.EventEmitter.call(this);
-};
-
-util.inherits(Bus, events.EventEmitter);
-
-var bus = new Bus();
-
-// /*
-var collected = {};
-bus.on('newListener', function (event) {
- debug('bus new listener: %s (%s)', event, bus.listeners(event).length);
- if (!collected[event]) {
- collected[event] = true;
- bus.on(event, function () {
- debug('bus emit: %s', event);
- });
- }
-});
-
-// */
-
-// proxy process messages (if forked) to the bus
-process.on('message', function (event) {
- debug('process.message(%s)', event);
- bus.emit(event);
-});
-
-var emit = bus.emit;
-
-// if nodemon was spawned via a fork, allow upstream communication
-// via process.send
-if (process.send) {
- bus.emit = function (event, data) {
- process.send({ type: event, data: data });
- emit.apply(bus, arguments);
- };
-}
-
-module.exports = bus;
diff --git a/node_modules/nodemon/lib/utils/clone.js b/node_modules/nodemon/lib/utils/clone.js
deleted file mode 100644
index 6ba6330..0000000
--- a/node_modules/nodemon/lib/utils/clone.js
+++ /dev/null
@@ -1,40 +0,0 @@
-module.exports = clone;
-
-// via http://stackoverflow.com/a/728694/22617
-function clone(obj) {
- // Handle the 3 simple types, and null or undefined
- if (null === obj || 'object' !== typeof obj) {
- return obj;
- }
-
- var copy;
-
- // Handle Date
- if (obj instanceof Date) {
- copy = new Date();
- copy.setTime(obj.getTime());
- return copy;
- }
-
- // Handle Array
- if (obj instanceof Array) {
- copy = [];
- for (var i = 0, len = obj.length; i < len; i++) {
- copy[i] = clone(obj[i]);
- }
- return copy;
- }
-
- // Handle Object
- if (obj instanceof Object) {
- copy = {};
- for (var attr in obj) {
- if (obj.hasOwnProperty && obj.hasOwnProperty(attr)) {
- copy[attr] = clone(obj[attr]);
- }
- }
- return copy;
- }
-
- throw new Error('Unable to copy obj! Its type isn\'t supported.');
-} \ No newline at end of file
diff --git a/node_modules/nodemon/lib/utils/colour.js b/node_modules/nodemon/lib/utils/colour.js
deleted file mode 100644
index 8c1b590..0000000
--- a/node_modules/nodemon/lib/utils/colour.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Encodes a string in a colour: red, yellow or green
- * @param {String} c colour to highlight in
- * @param {String} str the string to encode
- * @return {String} coloured string for terminal printing
- */
-function colour(c, str) {
- return (colour[c] || colour.black) + str + colour.black;
-}
-
-function strip(str) {
- re.lastIndex = 0; // reset position
- return str.replace(re, '');
-}
-
-colour.red = '\x1B[31m';
-colour.yellow = '\x1B[33m';
-colour.green = '\x1B[32m';
-colour.black = '\x1B[39m';
-
-var reStr = Object.keys(colour).map(key => colour[key]).join('|');
-var re = new RegExp(('(' + reStr + ')').replace(/\[/g, '\\['), 'g');
-
-colour.strip = strip;
-
-module.exports = colour;
diff --git a/node_modules/nodemon/lib/utils/index.js b/node_modules/nodemon/lib/utils/index.js
deleted file mode 100644
index c480338..0000000
--- a/node_modules/nodemon/lib/utils/index.js
+++ /dev/null
@@ -1,102 +0,0 @@
-var noop = function () { };
-var path = require('path');
-const semver = require('semver');
-var version = process.versions.node.split('.') || [null, null, null];
-
-var utils = (module.exports = {
- semver: semver,
- satisfies: test => semver.satisfies(process.versions.node, test),
- version: {
- major: parseInt(version[0] || 0, 10),
- minor: parseInt(version[1] || 0, 10),
- patch: parseInt(version[2] || 0, 10),
- },
- clone: require('./clone'),
- merge: require('./merge'),
- bus: require('./bus'),
- isWindows: process.platform === 'win32',
- isMac: process.platform === 'darwin',
- isLinux: process.platform === 'linux',
- isRequired: (function () {
- var p = module.parent;
- while (p) {
- // in electron.js engine it happens
- if (!p.filename) {
- return true;
- }
- if (p.filename.indexOf('bin' + path.sep + 'nodemon.js') !== -1) {
- return false;
- }
- p = p.parent;
- }
-
- return true;
- })(),
- home: process.env.HOME || process.env.HOMEPATH,
- quiet: function () {
- // nukes the logging
- if (!this.debug) {
- for (var method in utils.log) {
- if (typeof utils.log[method] === 'function') {
- utils.log[method] = noop;
- }
- }
- }
- },
- reset: function () {
- if (!this.debug) {
- for (var method in utils.log) {
- if (typeof utils.log[method] === 'function') {
- delete utils.log[method];
- }
- }
- }
- this.debug = false;
- },
- regexpToText: function (t) {
- return t
- .replace(/\.\*\\./g, '*.')
- .replace(/\\{2}/g, '^^')
- .replace(/\\/g, '')
- .replace(/\^\^/g, '\\');
- },
- stringify: function (exec, args) {
- // serializes an executable string and array of arguments into a string
- args = args || [];
-
- return [exec]
- .concat(
- args.map(function (arg) {
- // if an argument contains a space, we want to show it with quotes
- // around it to indicate that it is a single argument
- if (arg.length > 0 && arg.indexOf(' ') === -1) {
- return arg;
- }
- // this should correctly escape nested quotes
- return JSON.stringify(arg);
- })
- )
- .join(' ')
- .trim();
- },
-});
-
-utils.log = require('./log')(utils.isRequired);
-
-Object.defineProperty(utils, 'debug', {
- set: function (value) {
- this.log.debug = value;
- },
- get: function () {
- return this.log.debug;
- },
-});
-
-Object.defineProperty(utils, 'colours', {
- set: function (value) {
- this.log.useColours = value;
- },
- get: function () {
- return this.log.useColours;
- },
-});
diff --git a/node_modules/nodemon/lib/utils/log.js b/node_modules/nodemon/lib/utils/log.js
deleted file mode 100644
index 6580087..0000000
--- a/node_modules/nodemon/lib/utils/log.js
+++ /dev/null
@@ -1,82 +0,0 @@
-var colour = require('./colour');
-var bus = require('./bus');
-var required = false;
-var useColours = true;
-
-var coding = {
- log: 'black',
- info: 'yellow',
- status: 'green',
- detail: 'yellow',
- fail: 'red',
- error: 'red',
-};
-
-function log(type, text) {
- var msg = '[nodemon] ' + (text || '');
-
- if (useColours) {
- msg = colour(coding[type], msg);
- }
-
- // always push the message through our bus, using nextTick
- // to help testing and get _out of_ promises.
- process.nextTick(() => {
- bus.emit('log', { type: type, message: text, colour: msg });
- });
-
- // but if we're running on the command line, also echo out
- // question: should we actually just consume our own events?
- if (!required) {
- if (type === 'error') {
- console.error(msg);
- } else {
- console.log(msg || '');
- }
- }
-}
-
-var Logger = function (r) {
- if (!(this instanceof Logger)) {
- return new Logger(r);
- }
- this.required(r);
- return this;
-};
-
-Object.keys(coding).forEach(function (type) {
- Logger.prototype[type] = log.bind(null, type);
-});
-
-// detail is for messages that are turned on during debug
-Logger.prototype.detail = function (msg) {
- if (this.debug) {
- log('detail', msg);
- }
-};
-
-Logger.prototype.required = function (val) {
- required = val;
-};
-
-Logger.prototype.debug = false;
-Logger.prototype._log = function (type, msg) {
- if (required) {
- bus.emit('log', { type: type, message: msg || '', colour: msg || '' });
- } else if (type === 'error') {
- console.error(msg);
- } else {
- console.log(msg || '');
- }
-};
-
-Object.defineProperty(Logger.prototype, 'useColours', {
- set: function (val) {
- useColours = val;
- },
- get: function () {
- return useColours;
- },
-});
-
-module.exports = Logger;
diff --git a/node_modules/nodemon/lib/utils/merge.js b/node_modules/nodemon/lib/utils/merge.js
deleted file mode 100644
index 1f3440b..0000000
--- a/node_modules/nodemon/lib/utils/merge.js
+++ /dev/null
@@ -1,47 +0,0 @@
-var clone = require('./clone');
-
-module.exports = merge;
-
-function typesMatch(a, b) {
- return (typeof a === typeof b) && (Array.isArray(a) === Array.isArray(b));
-}
-
-/**
- * A deep merge of the source based on the target.
- * @param {Object} source [description]
- * @param {Object} target [description]
- * @return {Object} [description]
- */
-function merge(source, target, result) {
- if (result === undefined) {
- result = clone(source);
- }
-
- // merge missing values from the target to the source
- Object.getOwnPropertyNames(target).forEach(function (key) {
- if (source[key] === undefined) {
- result[key] = target[key];
- }
- });
-
- Object.getOwnPropertyNames(source).forEach(function (key) {
- var value = source[key];
-
- if (target[key] && typesMatch(value, target[key])) {
- // merge empty values
- if (value === '') {
- result[key] = target[key];
- }
-
- if (Array.isArray(value)) {
- if (value.length === 0 && target[key].length) {
- result[key] = target[key].slice(0);
- }
- } else if (typeof value === 'object') {
- result[key] = merge(value, target[key]);
- }
- }
- });
-
- return result;
-} \ No newline at end of file