diff --git a/lib/utils.ts b/lib/get-node-runtime-version.ts similarity index 55% rename from lib/utils.ts rename to lib/get-node-runtime-version.ts index 56510b5c..010f58ce 100644 --- a/lib/utils.ts +++ b/lib/get-node-runtime-version.ts @@ -1,4 +1,4 @@ -export function getRuntimeVersion(): number { +export default function getRuntimeVersion(): number { return parseInt(process.version.slice(1).split('.')[0], 10); } diff --git a/lib/index.ts b/lib/index.ts index 2ad54bd3..5158ccf8 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -2,10 +2,10 @@ import 'source-map-support/register'; import * as fs from 'fs'; import * as path from 'path'; import {LockfileParser, Lockfile, ManifestFile, PkgTree, - DepType, parseManifestFile} from './parsers/parser'; + DepType, parseManifestFile} from './parsers'; import {PackageLockParser} from './parsers/package-lock-parser'; import {YarnLockParser} from './parsers/yarn-lock-parse'; -import {getRuntimeVersion} from './utils'; +import getRuntimeVersion from './get-node-runtime-version'; enum LockfileType { npm = 'npm', diff --git a/lib/parsers/parser.ts b/lib/parsers/index.ts similarity index 84% rename from lib/parsers/parser.ts rename to lib/parsers/index.ts index a53cc410..e6dc6561 100644 --- a/lib/parsers/parser.ts +++ b/lib/parsers/index.ts @@ -36,16 +36,12 @@ export enum DepType { } export interface LockfileParser { - parseLockFile: parseLockFile; - getDependencyTree: getDependencyTree; + parseLockFile: (lockFileContents: string) + => Lockfile; + getDependencyTree: (manifestFile: ManifestFile, lockfile: Lockfile, includeDev?: boolean) + => Promise; } -export type parseLockFile = (lockFileContents: string) - => Lockfile; - -export type getDependencyTree = (manifestFile: ManifestFile, lockfile: Lockfile, includeDev?: boolean) - => Promise; - export type Lockfile = PackageLock | YarnLock; export function parseManifestFile(manifestFileContents: string): ManifestFile { diff --git a/lib/parsers/package-lock-parser.ts b/lib/parsers/package-lock-parser.ts index 79bdab52..6a2afff5 100644 --- a/lib/parsers/package-lock-parser.ts +++ b/lib/parsers/package-lock-parser.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; import {LockfileParser, PkgTree, Dep, DepType, ManifestFile, - getTopLevelDeps} from './parser'; + getTopLevelDeps} from './'; export interface PackageLock { name: string; diff --git a/lib/parsers/yarn-lock-parse.ts b/lib/parsers/yarn-lock-parse.ts index 097f1f3f..c84f990a 100644 --- a/lib/parsers/yarn-lock-parse.ts +++ b/lib/parsers/yarn-lock-parse.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; import {LockfileParser, PkgTree, Dep, DepType, ManifestFile, - getTopLevelDeps} from './parser'; + getTopLevelDeps} from './'; import getRuntimeVersion from '../get-node-runtime-version'; export interface YarnLock { diff --git a/test/lib/yarn.ts b/test/lib/yarn.ts index bbc49796..a67dbf77 100644 --- a/test/lib/yarn.ts +++ b/test/lib/yarn.ts @@ -5,7 +5,7 @@ // tslint:disable:object-literal-key-quotes import {test} from 'tap'; import {buildDepTreeFromFiles} from '../../lib'; -import {getRuntimeVersion} from '../../lib/utils'; +import getRuntimeVersion from '../../lib/get-node-runtime-version'; import * as fs from 'fs'; import * as _ from 'lodash';