From 1a1eb5a2e7678e0201e7093da9fa0236d4fb7104 Mon Sep 17 00:00:00 2001 From: Paul Marbach Date: Fri, 3 Jan 2020 14:09:14 -0500 Subject: [PATCH] fix: fix commander usage of args for positional args --- .../__fixtures__}/0/package.json | 0 .../__fixtures__}/12/package.json | 0 .../__fixtures__}/30/package.json | 0 .../index.test.ts} | 7 ++++--- .../{PostinstallTasks.ts => PostinstallTasks/index.ts} | 4 ++-- packages/web-scripts/src/index.ts | 4 ++-- 6 files changed, 8 insertions(+), 7 deletions(-) rename packages/web-scripts/src/Tasks/{__fixtures__/postinstall => PostinstallTasks/__fixtures__}/0/package.json (100%) rename packages/web-scripts/src/Tasks/{__fixtures__/postinstall => PostinstallTasks/__fixtures__}/12/package.json (100%) rename packages/web-scripts/src/Tasks/{__fixtures__/postinstall => PostinstallTasks/__fixtures__}/30/package.json (100%) rename packages/web-scripts/src/Tasks/{Postinstall.test.ts => PostinstallTasks/index.test.ts} (90%) rename packages/web-scripts/src/Tasks/{PostinstallTasks.ts => PostinstallTasks/index.ts} (93%) diff --git a/packages/web-scripts/src/Tasks/__fixtures__/postinstall/0/package.json b/packages/web-scripts/src/Tasks/PostinstallTasks/__fixtures__/0/package.json similarity index 100% rename from packages/web-scripts/src/Tasks/__fixtures__/postinstall/0/package.json rename to packages/web-scripts/src/Tasks/PostinstallTasks/__fixtures__/0/package.json diff --git a/packages/web-scripts/src/Tasks/__fixtures__/postinstall/12/package.json b/packages/web-scripts/src/Tasks/PostinstallTasks/__fixtures__/12/package.json similarity index 100% rename from packages/web-scripts/src/Tasks/__fixtures__/postinstall/12/package.json rename to packages/web-scripts/src/Tasks/PostinstallTasks/__fixtures__/12/package.json diff --git a/packages/web-scripts/src/Tasks/__fixtures__/postinstall/30/package.json b/packages/web-scripts/src/Tasks/PostinstallTasks/__fixtures__/30/package.json similarity index 100% rename from packages/web-scripts/src/Tasks/__fixtures__/postinstall/30/package.json rename to packages/web-scripts/src/Tasks/PostinstallTasks/__fixtures__/30/package.json diff --git a/packages/web-scripts/src/Tasks/Postinstall.test.ts b/packages/web-scripts/src/Tasks/PostinstallTasks/index.test.ts similarity index 90% rename from packages/web-scripts/src/Tasks/Postinstall.test.ts rename to packages/web-scripts/src/Tasks/PostinstallTasks/index.test.ts index 3147f6ee..852bfdce 100644 --- a/packages/web-scripts/src/Tasks/Postinstall.test.ts +++ b/packages/web-scripts/src/Tasks/PostinstallTasks/index.test.ts @@ -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); @@ -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', diff --git a/packages/web-scripts/src/Tasks/PostinstallTasks.ts b/packages/web-scripts/src/Tasks/PostinstallTasks/index.ts similarity index 93% rename from packages/web-scripts/src/Tasks/PostinstallTasks.ts rename to packages/web-scripts/src/Tasks/PostinstallTasks/index.ts index ddf0076b..67e4377c 100644 --- a/packages/web-scripts/src/Tasks/PostinstallTasks.ts +++ b/packages/web-scripts/src/Tasks/PostinstallTasks/index.ts @@ -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 diff --git a/packages/web-scripts/src/index.ts b/packages/web-scripts/src/index.ts index 8df157b8..fe51cfe0 100644 --- a/packages/web-scripts/src/index.ts +++ b/packages/web-scripts/src/index.ts @@ -271,11 +271,11 @@ function handleSpawnResult(result: SpawnSyncReturns) { } 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 } {