Skip to content

Commit

Permalink
fix(exec): parse full name from path
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Sep 8, 2021
1 parent 2162808 commit 96c5821
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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`
Expand All @@ -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`
Expand Down Expand Up @@ -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`
Expand All @@ -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`
Expand Down Expand Up @@ -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`
Expand All @@ -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`
Expand All @@ -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`
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand All @@ -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)_
<!-- commandsstop -->
7 changes: 6 additions & 1 deletion src/commands/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -34,7 +38,8 @@ export default class Exec extends Command {

public async run(): Promise<void> {
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);
Expand Down

0 comments on commit 96c5821

Please sign in to comment.