Skip to content

Commit

Permalink
Remove utile (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad committed Nov 21, 2020
1 parent 071cc04 commit b2120f9
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 88 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
3.0.4 / Sat, 21 Nov 2020
=========================

- [security] Update forever-monitor and remove utile to get rid of vulnerabilities

3.0.3 / Sat, 21 Nov 2020
=========================

Expand Down
32 changes: 16 additions & 16 deletions lib/forever.js
Expand Up @@ -6,20 +6,20 @@
*
*/

const fs = require("fs"),
path = require("path"),
events2 = require('eventemitter2'),
events = require("events"),
exec = require("child_process").exec,
spawn = require("child_process").spawn,
cliff = require("cliff"),
nconf = require("nconf"),
nssocket = require("nssocket"),
utile = require("utile"),
winston = require("winston"),
mkdirp = require("mkdirp"),
async = require("async"),
configUtils = require("./util/config-utils");
const fs = require("fs");
const path = require("path");
const events2 = require('eventemitter2');
const events = require("events");
const exec = require("child_process").exec;
const spawn = require("child_process").spawn;
const cliff = require("cliff");
const nconf = require("nconf");
const nssocket = require("nssocket");
const utils = require("./util/utils");
const winston = require("winston");
const mkdirp = require("mkdirp");
const async = require("async");
const configUtils = require("./util/config-utils");

const forever = exports;

Expand Down Expand Up @@ -428,7 +428,7 @@ forever.stat = function (logFile, script, callback) {
//
forever.start = function (script, options) {
if (!options.uid) {
options.uid = utile.randomString(4).replace(/^\-/, '_');
options.uid = utils.randomString(4).replace(/^\-/, '_');
}

if (!options.logFile) {
Expand All @@ -451,7 +451,7 @@ forever.start = function (script, options) {
//
forever.startDaemon = function (script, options) {
options = options || {};
options.uid = options.uid || utile.randomString(4).replace(/^\-/, '_');
options.uid = options.uid || utils.randomString(4).replace(/^\-/, '_');
options.logFile = forever.logFilePath(options.logFile || forever.config.get('logFile') || options.uid + '.log');
options.pidFile = forever.pidFilePath(options.pidFile || forever.config.get('pidFile') || options.uid + '.pid');

Expand Down
21 changes: 11 additions & 10 deletions lib/forever/worker.js
@@ -1,11 +1,12 @@
var events = require('events'),
fs = require('fs'),
path = require('path'),
nssocket = require('nssocket'),
utile = require('utile'),
forever = require(path.resolve(__dirname, '..', 'forever'));

var Worker = exports.Worker = function (options) {
const events = require('events');
const fs = require('fs');
const path = require('path');
const nssocket = require('nssocket');
const util = require('util');
const utils = require('../util/utils');
const forever = require(path.resolve(__dirname, '..', 'forever'));

const Worker = exports.Worker = function (options) {
events.EventEmitter.call(this);
options = options || {};

Expand All @@ -16,7 +17,7 @@ var Worker = exports.Worker = function (options) {
this._socket = null;
};

utile.inherits(Worker, events.EventEmitter);
util.inherits(Worker, events.EventEmitter);

Worker.prototype.start = function (callback) {
var self = this,
Expand Down Expand Up @@ -134,7 +135,7 @@ Worker.prototype.start = function (callback) {
//
var sock = self._sockFile = path.join(self.sockPath, [
'worker',
new Date().getTime() + utile.randomString(3),
new Date().getTime() + utils.randomString(3),
'sock'
].join('.'));

Expand Down
33 changes: 33 additions & 0 deletions lib/util/utils.js
@@ -0,0 +1,33 @@
//
// ### function randomString (length)
// #### @length {integer} The number of bits for the random base64 string returned to contain
// randomString returns a pseude-random ASCII string (subset)
// the return value is a string of length ⌈bits/6⌉ of characters
// from the base64 alphabet.
//
function randomString(length) {
let rand, i, ret, bits;
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
const mod = 4;

ret = '';
// standard 4
// default is 16
bits = length * mod || 64;

// in v8, Math.random() yields 32 pseudo-random bits (in spidermonkey it gives 53)
while (bits > 0) {
// 32-bit integer
rand = Math.floor(Math.random() * 0x100000000);
//we use the top bits
for (i = 26; i > 0 && bits > 0; i -= mod, bits -= mod) {
ret += chars[0x3f & (rand >>> i)];
}
}

return ret;
}

module.exports = {
randomString,
};
83 changes: 24 additions & 59 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "forever",
"preferGlobal": "true",
"description": "A simple CLI tool for ensuring that a given node script runs continuously (i.e. forever)",
"version": "3.0.3",
"version": "3.0.4",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
"maintainers": [
"Igor Savin <iselwin@gmail.com>"
Expand All @@ -25,14 +25,13 @@
"deep-equal": "^1.1.1",
"eventemitter2": "6.4.3",
"flatiron": "~0.4.3",
"forever-monitor": "^3.0.2",
"forever-monitor": "^3.0.3",
"mkdirp": "^0.5.5",
"nconf": "^0.10.0",
"nssocket": "^0.6.0",
"object-assign": "^4.1.1",
"prettyjson": "^1.2.1",
"shush": "^1.0.0",
"utile": "~0.3.0",
"winston": "~0.8.1",
"yargs": "^3.32.0"
},
Expand Down

0 comments on commit b2120f9

Please sign in to comment.