From 819d8f35c1d2e58b509a14366160192e0e80b3c2 Mon Sep 17 00:00:00 2001 From: Nick Baugh Date: Sun, 10 Sep 2017 21:41:33 -0400 Subject: [PATCH] Fixed deps, Fixed README --- README.md | 5 +---- index.js | 12 +++++------- package.json | 3 ++- yarn.lock | 8 +++++++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e41a41c..c2e3bc0 100644 --- a/README.md +++ b/README.md @@ -47,17 +47,15 @@ const agenda = new Agenda(); stopAgenda(agenda).then().catch(console.error); ``` -> With advanced options including custom logger `logger`, cancel query `cancelQuery`, and check interval in milliseconds `checkIntervalMs`: +> With advanced options including custom cancel query `cancelQuery` and check interval in milliseconds `checkIntervalMs`: ```js const stopAgenda = require('stop-agenda'); const Agenda = require('agenda'); -const Logger = require('@ladjs/logger'); const agenda = new Agenda(); stopAgenda(agenda, { - logger: new Logger(), cancelQuery: { repeatInterval: { $exists: true, @@ -78,7 +76,6 @@ stopAgenda(agenda, { ```js { - logger: console, cancelQuery: { repeatInterval: { $exists: true, diff --git a/index.js b/index.js index d77900b..3684bcf 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,11 @@ -const Agenda = require('agenda'); +const debug = require('debug')('stop-agenda'); const stopAgenda = (agenda, config = {}) => { - if (!(agenda instanceof Agenda)) + if (typeof agenda !== 'object') throw new Error('`agenda` must be an instance of Agenda'); config = Object.assign( { - logger: console, cancelQuery: { repeatInterval: { $exists: true, @@ -36,7 +35,7 @@ const stopAgenda = (agenda, config = {}) => { return reject(new Error('collection did not exist, see agenda#501')); agenda.cancel(config.cancelQuery, (err, numRemoved) => { if (err) return reject(err); - config.logger.info(`cancelled ${numRemoved} jobs`); + debug(`cancelled ${numRemoved} jobs`); resolve(); }); }), @@ -44,9 +43,7 @@ const stopAgenda = (agenda, config = {}) => { // check every X ms for jobs still running const jobInterval = setInterval(() => { if (agenda._runningJobs.length > 0) { - config.logger.info( - `${agenda._runningJobs.length} jobs still running` - ); + debug(`${agenda._runningJobs.length} jobs still running`); } else { clearInterval(jobInterval); // cancel recurring jobs so they get redefined on next server start @@ -56,6 +53,7 @@ const stopAgenda = (agenda, config = {}) => { return reject( new Error('collection did not exist, see agenda#501') ); + debug('attempting to run agenda.stop', agenda.stop); agenda.stop(err => { if (err) return reject(err); resolve(); diff --git a/package.json b/package.json index 6c18d57..8006041 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,10 @@ "Nick Baugh (http://niftylettuce.com/)" ], "dependencies": { - "agenda": "^1.0.0" + "debug": "^3.0.1" }, "devDependencies": { + "agenda": "^1.0.0", "ava": "^0.22.0", "codecov": "^2.3.0", "cross-env": "^5.0.5", diff --git a/yarn.lock b/yarn.lock index 216b8f1..0097050 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1179,6 +1179,12 @@ debug@^2.1.1, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: dependencies: ms "2.0.0" +debug@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.0.1.tgz#0564c612b521dc92d9f2988f0549e34f9c98db64" + dependencies: + ms "2.0.0" + debug@~0.7.2: version "0.7.4" resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" @@ -3955,7 +3961,7 @@ remark-heading-gap@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/remark-heading-gap/-/remark-heading-gap-3.0.0.tgz#f52ac47a27995ef3248a59eb7544b5620b4736a6" -"remark-license@github:niftylettuce/remark-license": +remark-license@niftylettuce/remark-license: version "4.0.1" resolved "https://codeload.github.com/niftylettuce/remark-license/tar.gz/17ecb8f64f8f6082414d14f9267a12764e6ddbfb" dependencies: