-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bin): created separate bin file, fixes #23
- Loading branch information
Showing
5 changed files
with
55 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
registry=http://registry.npmjs.org/ | ||
progress=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict' | ||
|
||
var argv = require('optimist').argv; | ||
var check = require('..'); | ||
var path = require('path'); | ||
|
||
function isPackageJson(filename) { | ||
return /package\.json$/.test(filename); | ||
} | ||
|
||
function isBowerJson(filename) { | ||
return /bower\.json$/.test(filename); | ||
} | ||
|
||
if (argv.version) { | ||
var pkg = require('./package.json'); | ||
console.log(pkg.name, pkg.version); | ||
process.exit(0); | ||
return; | ||
} | ||
|
||
var dir = process.cwd(); | ||
if (argv.filename) { | ||
if (argv.verbose) { | ||
console.log('checking', argv.filename); | ||
} | ||
if (isPackageJson(argv.filename) || isBowerJson(argv.filename)) { | ||
dir = path.dirname(argv.filename); | ||
} else { | ||
dir = argv.filename; | ||
} | ||
dir = path.resolve(dir); | ||
} | ||
|
||
if (argv.verbose) { | ||
console.log('checking deps', dir); | ||
} | ||
var ok = check(dir, Boolean(argv.verbose)); | ||
process.exit(ok ? 0 : 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1 @@ | ||
#!/usr/bin/env node | ||
|
||
var argv = require('optimist').argv; | ||
var check = require('./src/check-folder'); | ||
var path = require('path'); | ||
|
||
function isPackageJson(filename) { | ||
return /package\.json$/.test(filename); | ||
} | ||
|
||
function isBowerJson(filename) { | ||
return /bower\.json$/.test(filename); | ||
} | ||
|
||
if (!module.parent) { | ||
|
||
if (argv.version) { | ||
var pkg = require('./package.json'); | ||
console.log(pkg.name, pkg.version); | ||
process.exit(0); | ||
return; | ||
} | ||
|
||
var dir = process.cwd(); | ||
if (argv.filename) { | ||
if (argv.verbose) { | ||
console.log('checking', argv.filename); | ||
} | ||
if (isPackageJson(argv.filename) || isBowerJson(argv.filename)) { | ||
dir = path.dirname(argv.filename); | ||
} else { | ||
dir = argv.filename; | ||
} | ||
dir = path.resolve(dir); | ||
} | ||
|
||
if (argv.verbose) { | ||
console.log('checking deps', dir); | ||
} | ||
var ok = check(dir, Boolean(argv.verbose)); | ||
process.exit(ok ? 0 : 1); | ||
return; | ||
} | ||
|
||
module.exports = check; | ||
module.exports = require('./src/check-folder'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "deps-ok", | ||
"description": "Fast checking of top level dependencies based on version numbers", | ||
"author": "Gleb Bahmutov <[email protected]>", | ||
"bin": "index.js", | ||
"bin": "bin/deps-ok.js", | ||
"version": "0.0.0-semantic-release", | ||
"bugs": { | ||
"url": "https://github.com/bahmutov/deps-ok/issues" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
join = require('path').join | ||
relative = join.bind(null, __dirname) | ||
check = require '..' | ||
|
||
gt.module 'e2e NPM tests in root folder', | ||
setup: -> | ||
process.chdir join(__dirname, '..') | ||
process.chdir relative('..') | ||
teardown: -> | ||
process.chdir __dirname | ||
|
||
gt.async 'test itself', -> | ||
gt.exec 'node', ['index.js', '--verbose'], 0, | ||
gt.exec 'node', ['bin/deps-ok.js', '--verbose'], 0, | ||
'this module has all dependencies' | ||
|
||
gt.module 'e2e NPM tests in this folder' | ||
|
||
args = ['../bin/deps-ok.js', '--verbose', '--filename'] | ||
|
||
gt.async 'test itself with folder', -> | ||
gt.exec 'node', ['../index.js', '--verbose', '--filename', join(__dirname, '..')], 0, | ||
gt.exec 'node', args.concat(relative('..')), 0, | ||
'this module has all dependencies' | ||
|
||
gt.async 'test itself with package.json path', -> | ||
gt.exec 'node', ['../index.js', '--verbose', '--filename', join(__dirname, '../package.json')], 0, | ||
gt.exec 'node', args.concat(relative('../package.json')), 0, | ||
'this module has all dependencies' | ||
|
||
gt.async 'test version with latest keyword', -> | ||
gt.exec 'node', ['../index.js', '--verbose', '--filename', join(__dirname, './package-with-latest.json')], 1, | ||
gt.exec 'node', args.concat(relative('./package-with-latest.json')), 1, | ||
'this has some missing dependencies' | ||
|
||
gt.async 'test version with github version', -> | ||
gt.exec 'node', ['../index.js', '--verbose', '--filename', join(__dirname, './package-with-github.json')], 0, | ||
gt.exec 'node', args.concat(relative('./package-with-github.json')), 0, | ||
'this handles github: version string' | ||
|
||
gt.async 'test non-existing file', -> | ||
gt.exec 'node', ['../index.js', '--verbose', '--filename', join(__dirname, './does-not-exist.json')], 1, | ||
gt.exec 'node', args.concat(relative('./does-not-exist.json')), 1, | ||
'package file does not exist' |