Skip to content

Commit

Permalink
chore: remove utils + rename parsers/parse to index + inline interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Mila Votradovec committed Aug 24, 2018
1 parent 82e888c commit 8348438
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/utils.ts → lib/get-node-runtime-version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

export function getRuntimeVersion(): number {
export default function getRuntimeVersion(): number {
return parseInt(process.version.slice(1).split('.')[0], 10);
}
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 4 additions & 8 deletions lib/parsers/parser.ts → lib/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PkgTree>;
}

export type parseLockFile = (lockFileContents: string)
=> Lockfile;

export type getDependencyTree = (manifestFile: ManifestFile, lockfile: Lockfile, includeDev?: boolean)
=> Promise<PkgTree>;

export type Lockfile = PackageLock | YarnLock;

export function parseManifestFile(manifestFileContents: string): ManifestFile {
Expand Down
2 changes: 1 addition & 1 deletion lib/parsers/package-lock-parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _ from 'lodash';
import {LockfileParser, PkgTree, Dep, DepType, ManifestFile,
getTopLevelDeps} from './parser';
getTopLevelDeps} from './';

export interface PackageLock {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/parsers/yarn-lock-parse.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 8348438

Please sign in to comment.