Skip to content

Commit

Permalink
refactor(core): apply changes from updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Aug 1, 2021
1 parent 91254f6 commit c3aac26
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 40 deletions.
18 changes: 10 additions & 8 deletions src/bin-fix-mismatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import chalk from 'chalk';
import { fixMismatchesToDisk } from './commands/fix-mismatches';
import { option } from './constants';
import { option, SyncpackConfig } from './constants';
import { getConfig } from './lib/get-config';
import program = require('commander');
import { program } from 'commander';

program.description(
`
Expand Down Expand Up @@ -55,13 +55,15 @@ program
.option(...option.indent)
.parse(process.argv);

const args = program as Partial<SyncpackConfig>;

fixMismatchesToDisk(
getConfig({
dev: program.dev,
filter: program.filter,
indent: program.indent,
peer: program.peer,
prod: program.prod,
source: program.source,
dev: args.dev,
filter: args.filter,
indent: args.indent,
peer: args.peer,
prod: args.prod,
source: args.source,
}),
);
10 changes: 6 additions & 4 deletions src/bin-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import chalk from 'chalk';
import { formatToDisk } from './commands/format';
import { option } from './constants';
import { option, SyncpackConfig } from './constants';
import { getConfig } from './lib/get-config';
import program = require('commander');
import { program } from 'commander';

program.description(
`
Expand Down Expand Up @@ -46,9 +46,11 @@ program
.option(...option.indent)
.parse(process.argv);

const args = program as Partial<SyncpackConfig>;

formatToDisk(
getConfig({
indent: program.indent,
source: program.source,
indent: args.indent,
source: args.source,
}),
);
16 changes: 9 additions & 7 deletions src/bin-list-mismatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import chalk from 'chalk';
import { listMismatchesFromDisk } from './commands/list-mismatches';
import { option } from './constants';
import { option, SyncpackConfig } from './constants';
import { getConfig } from './lib/get-config';
import program = require('commander');
import { program } from 'commander';

program.description(
`
Expand Down Expand Up @@ -51,12 +51,14 @@ program
.option(...option.filter)
.parse(process.argv);

const args = program as Partial<SyncpackConfig>;

listMismatchesFromDisk(
getConfig({
dev: program.dev,
filter: program.filter,
peer: program.peer,
prod: program.prod,
source: program.source,
dev: args.dev,
filter: args.filter,
peer: args.peer,
prod: args.prod,
source: args.source,
}),
);
16 changes: 9 additions & 7 deletions src/bin-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import chalk from 'chalk';
import { listFromDisk } from './commands/list';
import { option } from './constants';
import { option, SyncpackConfig } from './constants';
import { getConfig } from './lib/get-config';
import program = require('commander');
import { program } from 'commander';

program.description(' List all dependencies required by your packages.');

Expand Down Expand Up @@ -47,12 +47,14 @@ program
.option(...option.filter)
.parse(process.argv);

const args = program as Partial<SyncpackConfig>;

listFromDisk(
getConfig({
dev: program.dev,
filter: program.filter,
peer: program.peer,
prod: program.prod,
source: program.source,
dev: args.dev,
filter: args.filter,
peer: args.peer,
prod: args.prod,
source: args.source,
}),
);
20 changes: 11 additions & 9 deletions src/bin-set-semver-ranges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import chalk from 'chalk';
import { setSemverRangesToDisk } from './commands/set-semver-ranges';
import { option } from './constants';
import { option, SyncpackConfig } from './constants';
import { getConfig } from './lib/get-config';
import program = require('commander');
import { program } from 'commander';

program.description(
`
Expand Down Expand Up @@ -67,14 +67,16 @@ program
.option(...option.semverRange)
.parse(process.argv);

const args = program as Partial<SyncpackConfig>;

setSemverRangesToDisk(
getConfig({
dev: program.dev,
filter: program.filter,
indent: program.indent,
peer: program.peer,
prod: program.prod,
semverRange: program.semverRange,
source: program.source,
dev: args.dev,
filter: args.filter,
indent: args.indent,
peer: args.peer,
prod: args.prod,
semverRange: args.semverRange,
source: args.source,
}),
);
2 changes: 1 addition & 1 deletion src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import program = require('commander');
import { program } from 'commander';

program
.version(require('../package.json').version)
Expand Down
6 changes: 4 additions & 2 deletions src/commands/lib/matches-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import { InstalledPackage } from './installations/get-dependencies';

type Options = Pick<SyncpackConfig, 'filter'>;

export const matchesFilter = (options: { filter: string }) => ({ name }: InstalledPackage): boolean =>
name.search(new RegExp(options.filter)) !== -1;
export const matchesFilter =
(options: Options) =>
({ name }: InstalledPackage): boolean =>
name.search(new RegExp(options.filter)) !== -1;
2 changes: 1 addition & 1 deletion src/commands/lib/write-if-changed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('writeIfChanged', () => {

afterEach(() => {
jest.restoreAllMocks();
jest.resetModuleRegistry();
jest.resetModules();
});

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getConfig = (program: Partial<SyncpackConfig>): SyncpackConfig => {
if (isValid(configOption)) {
return configOption;
}
return (DEFAULT_CONFIG[name] as unknown) as T;
return DEFAULT_CONFIG[name] as unknown as T;
};

const isVersionGroup = (value: any): value is VersionGroup =>
Expand Down

0 comments on commit c3aac26

Please sign in to comment.