Skip to content

Commit e48b713

Browse files
author
Mila Votradovec
committed
feat: add bin command
1 parent d95b01a commit e48b713

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

bin/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env node
2+
const inspect = require('../dist/index')
3+
4+
inspect.buildDepTreeFromFiles('./', 'package.json', 'package-lock.json')
5+
.then((tree) => {
6+
console.log(JSON.stringify(tree));
7+
})
8+
.catch((e) => {
9+
console.log(e);
10+
});

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "snyk-nodejs-lockfile-parser",
33
"description": "Generate a dep tree given a lockfile",
44
"main": "dist/lib/index.js",
5+
"bin": {
6+
"parse": "./bin/index.js"
7+
},
58
"scripts": {
69
"test": "npm run lint && npm run unit-test",
710
"unit-test": "tap test/lib -R=spec --timeout=300 --node-path ts-node --test-file-pattern '/\\.[tj]s$/'",

test/lib/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// See: https://github.com/tapjs/node-tap/issues/313#issuecomment-250067741
44
// tslint:disable:max-line-length
55
// tslint:disable:object-literal-key-quotes
6-
import { test } from 'tap';
6+
import {test} from 'tap';
77
import * as sinon from 'sinon';
8-
import parseLockFile from '../../lib';
8+
import {buildDepTreeFromFiles} from '../../lib';
99
import * as fs from 'fs';
1010

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

17-
const depTree = await parseLockFile(
17+
const depTree = await buildDepTreeFromFiles(
1818
`${__dirname}/fixtures/goof/`,
1919
'package.json',
2020
'package-lock.json',

0 commit comments

Comments
 (0)