mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
Since the `vc project` command is about to be expanded with 2 new subcommands, I think it makes sense to do a little bit of refactoring. The current `vc project` command is all in one file, with the logic for subcommands nested within if statements. I think the structure of `vc project` should look more like `vc env`, which is consistent with how commands with subcommands look throughout the rest of the codebase.
This PR moves the logic for the `project` subcommands into their own files.
### 📋 Checklist
<!--
Please keep your PR as a Draft until the checklist is complete
-->
#### Tests
- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`
#### Code Review
- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
20 lines
436 B
TypeScript
20 lines
436 B
TypeScript
export function getDataFromIntro(output: string): {
|
|
project: string | undefined;
|
|
org: string | undefined;
|
|
} {
|
|
const project = output.match(/(?<=Deployments for )(.*)(?= under)/);
|
|
const org = output.match(/(?<=under )(.*)(?= \[)/);
|
|
|
|
return {
|
|
project: project?.[0],
|
|
org: org?.[0],
|
|
};
|
|
}
|
|
|
|
export function parseTable(output: string): string[] {
|
|
return output
|
|
.trim()
|
|
.replace(/ {1} +/g, ',')
|
|
.split(',');
|
|
}
|