Skip to content

Commit

Permalink
feat: add bin command
Browse files Browse the repository at this point in the history
  • Loading branch information
Mila Votradovec committed Aug 9, 2018
1 parent d95b01a commit e48b713
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env node
const inspect = require('../dist/index')

inspect.buildDepTreeFromFiles('./', 'package.json', 'package-lock.json')
.then((tree) => {
console.log(JSON.stringify(tree));
})
.catch((e) => {
console.log(e);
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "snyk-nodejs-lockfile-parser",
"description": "Generate a dep tree given a lockfile",
"main": "dist/lib/index.js",
"bin": {
"parse": "./bin/index.js"
},
"scripts": {
"test": "npm run lint && npm run unit-test",
"unit-test": "tap test/lib -R=spec --timeout=300 --node-path ts-node --test-file-pattern '/\\.[tj]s$/'",
Expand Down
6 changes: 3 additions & 3 deletions test/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// See: https://github.com/tapjs/node-tap/issues/313#issuecomment-250067741
// tslint:disable:max-line-length
// tslint:disable:object-literal-key-quotes
import { test } from 'tap';
import {test} from 'tap';
import * as sinon from 'sinon';
import parseLockFile from '../../lib';
import {buildDepTreeFromFiles} from '../../lib';
import * as fs from 'fs';

const load = (filename) => fs.readFileSync(
Expand All @@ -14,7 +14,7 @@ const load = (filename) => fs.readFileSync(
test('Parse npm package-lock.json', async (t) => {
const expectedDepTree = load('goof/dep-tree_small.json');

const depTree = await parseLockFile(
const depTree = await buildDepTreeFromFiles(
`${__dirname}/fixtures/goof/`,
'package.json',
'package-lock.json',
Expand Down

0 comments on commit e48b713

Please sign in to comment.