Skip to content

Commit

Permalink
feat: add debug module use DEBUG=deps-ok
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Apr 7, 2018
1 parent 51e5fb8 commit 126a671
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ gulp.task('default', ['deps-ok', ...]);
This check will reject packages without "version" property in the `package.json`
file.

## Debug

See debug messages by running module with `DEBUG=deps-ok` environment variable

## Small print

Author: Gleb Bahmutov © 2013
Expand Down
17 changes: 12 additions & 5 deletions bin/deps-ok.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

'use strict'

var argv = require('optimist').argv;
var check = require('..');
var path = require('path');
var FAIL_EXIT_CODE = -1;
var SUCCESS = 0;
const debug = require('debug')('deps-ok')
const argv = require('minimist')(process.argv.slice(2))
const check = require('..');
const path = require('path');
const FAIL_EXIT_CODE = -1;
const SUCCESS = 0;

debug('arguments %j', argv)

function isPackageJson(filename) {
return /package\.json$/.test(filename);
Expand All @@ -25,6 +28,8 @@ if (argv.version) {

var dir = process.cwd();
if (argv.filename) {
debug('checking file %s', argv.filename)

if (argv.verbose) {
console.log('checking', argv.filename);
}
Expand All @@ -36,8 +41,10 @@ if (argv.filename) {
dir = path.resolve(dir);
}

debug('checking dependencies in folder %s', dir)
if (argv.verbose) {
console.log('checking deps', dir);
}

var ok = check(dir, Boolean(argv.verbose));
process.exit(ok ? SUCCESS : FAIL_EXIT_CODE);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
],
"dependencies": {
"check-more-types": "2.24.0",
"debug": "3.1.0",
"lazy-ass": "1.6.0",
"lodash": "4.17.5",
"optimist": "0.6.1",
"minimist": "1.2.0",
"q": "2.0.3",
"quote": "0.4.0",
"semver": "5.5.0"
Expand Down

0 comments on commit 126a671

Please sign in to comment.