Skip to content

Commit

Permalink
fix: fix commander usage of args for positional args
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Marbach committed Jan 3, 2020
1 parent 3bf99c6 commit 1a1eb5a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { postinstallTask } from './PostinstallTasks';
import { THIS_ROOT } from '../Paths';
import { join } from 'path';

import { postinstallTask } from '.';

// @ts-ignore
jest.spyOn(process, 'exit').mockImplementation(c => c);
Expand Down Expand Up @@ -36,7 +37,7 @@ describe('web-scripts postinstall', () => {
`(
'return status code $status when audited dependencies have $violations violations and $threshold threshold',
async ({ violations, threshold, status }) => {
const source = `${THIS_ROOT}/src/Tasks/__fixtures__/postinstall/${violations}`;
const source = join(__dirname, '__fixtures__', violations.toString());

await postinstallTask({
name: 'postinstall',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { default as spawn } from 'cross-spawn-promise';
import { default as Debug } from 'debug';

import { PostinstallTaskDesc } from '../SharedTypes';
import { CONSUMING_ROOT } from '../Paths';
import { PostinstallTaskDesc } from '../../SharedTypes';
import { CONSUMING_ROOT } from '../../Paths';

const dbg = Debug('web-scripts:postinstall'); // eslint-disable-line new-cap

Expand Down
4 changes: 2 additions & 2 deletions packages/web-scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ function handleSpawnResult(result: SpawnSyncReturns<Buffer>) {
}

function getCommand(args: any[]): Command {
return args[args.length - 1] as Command;
return args[0] as Command;
}

function getPositionalArgs(args: any[]): string[] {
return args.slice(0, args.length - 1) as string[];
return args.slice(1) as string[];
}

function getOpts(cmd: Command): { [key: string]: any } {
Expand Down

0 comments on commit 1a1eb5a

Please sign in to comment.