Updated deps and brought in relative-date module b/c it kept getting updated to a version that does not exist

This commit is contained in:
ポール ウェッブ 2018-07-13 17:20:14 -05:00
parent c8926b8fa1
commit 5347b30403
3 changed files with 62 additions and 5 deletions

58
modules/relative-date.js Normal file
View file

@ -0,0 +1,58 @@
"use strict";
// P R O G R A M
const relativeDate = (function (undefined) {
const SECOND = 1000;
const MINUTE = 60 * SECOND;
const HOUR = 60 * MINUTE;
const DAY = 24 * HOUR;
const WEEK = 7 * DAY;
const YEAR = DAY * 365;
const MONTH = YEAR / 12;
const formats = [
[ 0.7 * MINUTE, "just now" ],
[ 1.5 * MINUTE, "a minute ago" ],
[ 60 * MINUTE, "minutes ago", MINUTE ],
[ 1.5 * HOUR, "an hour ago" ],
[ DAY, "hours ago", HOUR ],
[ 2 * DAY, "yesterday" ],
[ 7 * DAY, "days ago", DAY ],
[ 1.5 * WEEK, "a week ago" ],
[ MONTH, "weeks ago", WEEK ],
[ 1.5 * MONTH, "a month ago" ],
[ YEAR, "months ago", MONTH ],
[ 1.5 * YEAR, "a year ago" ],
[ Number.MAX_VALUE, "years ago", YEAR ]
];
function relativeDate(input, reference) {
!reference && (reference = (new Date).getTime());
reference instanceof Date && (reference = reference.getTime());
input instanceof Date && (input = input.getTime());
const delta = reference - input;
const len = formats.length;
for (let i = -1; ++i < len;) {
const format = formats[i];
if (delta < format[0]) {
return format[2] === undefined ? format[1] : Math.round(delta / format[2]) + " " + format[1];
}
}
}
return relativeDate;
})();
// E X P O R T
if (typeof module !== "undefined" && module.exports) {
module.exports = exports = relativeDate;
}

View file

@ -38,7 +38,6 @@
"markdown-it-wikilinks": "^1.0.1",
"nanohtml": "^1.2.4",
"redis": "^2.8.0",
"relative-date": "^1.1.3",
"request-promise-native": "^1.0.5",
"slack-node": "^0.2.0",
"socket.io": "^2.1.1",
@ -48,12 +47,12 @@
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"choo-devtools": "^2.5.1",
"nodemon": "^1.18.1",
"nodemon": "^1.18.2",
"npm-run-all": "^4.1.3",
"sass": "^1.9.1",
"sass": "^1.9.2",
"snazzy": "^7.1.1",
"standardx": "^2.1.0",
"updates": "^3.2.1"
"updates": "^3.2.2"
},
"peerDependencies": {
"request": "^2.87.0"

View file

@ -17,7 +17,6 @@ const fastify = require("fastify")({
const octokit = require("@octokit/rest")();
const redis = require("redis");
const relativeDate = require("relative-date");
const local = require("app-root-path").require;
// V A R I A B L E S
@ -25,6 +24,7 @@ const local = require("app-root-path").require;
const github = local("/helpers/github");
const log = console.log; // eslint-disable-line
const logSlackError = local("/helpers/slack");
const relativeDate = local("/modules/relative-date");
let client;
if (typeof process.env.GITHUB_OAUTH_TOKEN !== "undefined") {