diff --git a/README.md b/README.md index b4802ba7..4b5a963f 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ EXAMPLES $ multi add https://github.com/my-github-org/my-repo ``` -_See code: [src/commands/add.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/add.ts)_ +_See code: [src/commands/add.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/add.ts)_ ## `multi cd REPO` @@ -130,7 +130,7 @@ DESCRIPTION cd into a repository. ``` -_See code: [src/commands/cd.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/cd.ts)_ +_See code: [src/commands/cd.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/cd.ts)_ ## `multi diff ORG` @@ -150,7 +150,7 @@ EXAMPLES $ multi diff my-github-org ``` -_See code: [src/commands/diff.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/diff.ts)_ +_See code: [src/commands/diff.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/diff.ts)_ ## `multi exec REPO` @@ -183,7 +183,7 @@ EXAMPLES $ multi exec . open https://app.circleci.com/pipelines/github/{repo.fullName} ``` -_See code: [src/commands/exec.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/exec.ts)_ +_See code: [src/commands/exec.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/exec.ts)_ ## `multi list` @@ -200,7 +200,7 @@ ALIASES $ multi ls ``` -_See code: [src/commands/list.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/list.ts)_ +_See code: [src/commands/list.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/list.ts)_ ## `multi open REPO` @@ -238,7 +238,7 @@ EXAMPLES $ multi open my-repo --file path/to/my/code.ts ``` -_See code: [src/commands/open.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/open.ts)_ +_See code: [src/commands/open.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/open.ts)_ ## `multi remove REPO` @@ -258,7 +258,7 @@ ALIASES $ multi rm ``` -_See code: [src/commands/remove.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/remove.ts)_ +_See code: [src/commands/remove.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/remove.ts)_ ## `multi setup` @@ -275,7 +275,7 @@ DESCRIPTION Setup multi ``` -_See code: [src/commands/setup.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/setup.ts)_ +_See code: [src/commands/setup.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/setup.ts)_ ## `multi task KEYVALUE` @@ -314,7 +314,7 @@ EXAMPLES $ multi task build --interactive ``` -_See code: [src/commands/task.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/task.ts)_ +_See code: [src/commands/task.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/task.ts)_ ## `multi task get TASK` @@ -349,7 +349,7 @@ ALIASES $ multi v ``` -_See code: [src/commands/view.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/view.ts)_ +_See code: [src/commands/view.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/view.ts)_ ## `multi where REPO` @@ -369,5 +369,5 @@ DESCRIPTION Print location of a repository. ``` -_See code: [src/commands/where.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.1/src/commands/where.ts)_ +_See code: [src/commands/where.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v2.1.2/src/commands/where.ts)_ diff --git a/src/commands/exec.ts b/src/commands/exec.ts index 77f8f623..822d31db 100644 --- a/src/commands/exec.ts +++ b/src/commands/exec.ts @@ -4,6 +4,10 @@ import { exec } from 'shelljs'; import { get } from 'lodash'; import { Repos } from '../repos'; +function parseRepoNameFromPath(): string { + return process.cwd().split(path.sep).reverse().slice(0, 2).reverse().join(path.sep); +} + export default class Exec extends Command { public static description = 'Execute a command or script in a repository.'; public static examples = [ @@ -34,7 +38,8 @@ export default class Exec extends Command { public async run(): Promise { const { args, argv } = await this.parse(Exec); - const repoName = (args.repo === '.' ? path.basename(process.cwd()) : args.repo) as string; + const repoName = (args.repo === '.' ? parseRepoNameFromPath() : args.repo) as string; + let executable = argv.splice(argv.indexOf(args.repo) + 1).join(' '); const repo = (await Repos.create()).getOne(repoName);