nx/docs/generated/devkit/parseTargetString.md
Juri Strumpflohner b51676a89a
docs(core): restructure guides into technologies sections (#31288)
Updates the docs structure, navigation etc to be easier + better suited
for showing Nx technology support beyond just TS.

**Notes:**

- API (`/nx-api`) tab is removed from the navigation (i.e. menu bar),
but pages still remain for now until we update references in `*.md`
files.
- Redirects are set up `/nx-api` to go to their respect new location
e.g. `/technologies` or `/reference/core-api`
- Old URLs still exist in the sitemap for now, but majority of them will
be redirected -- a follow-up PR can remove them.

**Preview:**
https://nx-dev-git-nx-dev-polyglot-docs-restructure-nrwl.vercel.app/docs

---------

Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
2025-05-29 14:55:34 -04:00

48 lines
2.1 KiB
Markdown

# Function: parseTargetString
**parseTargetString**(`targetString`, `projectGraph`): [`Target`](/reference/core-api/devkit/documents/Target)
Parses a target string into {project, target, configuration}
Examples:
```typescript
parseTargetString('proj:test', graph); // returns { project: "proj", target: "test" }
parseTargetString('proj:test:production', graph); // returns { project: "proj", target: "test", configuration: "production" }
```
#### Parameters
| Name | Type | Description |
| :------------- | :------------------------------------------------------------------ | :--------------- |
| `targetString` | `string` | target reference |
| `projectGraph` | [`ProjectGraph`](/reference/core-api/devkit/documents/ProjectGraph) | - |
#### Returns
[`Target`](/reference/core-api/devkit/documents/Target)
**parseTargetString**(`targetString`, `ctx`): [`Target`](/reference/core-api/devkit/documents/Target)
Parses a target string into {project, target, configuration}. Passing a full
[ExecutorContext](/reference/core-api/devkit/documents/ExecutorContext) enables the targetString to reference the current project.
Examples:
```typescript
parseTargetString('test', executorContext); // returns { project: "proj", target: "test" }
parseTargetString('proj:test', executorContext); // returns { project: "proj", target: "test" }
parseTargetString('proj:test:production', executorContext); // returns { project: "proj", target: "test", configuration: "production" }
```
#### Parameters
| Name | Type |
| :------------- | :------------------------------------------------------------------------ |
| `targetString` | `string` |
| `ctx` | [`ExecutorContext`](/reference/core-api/devkit/documents/ExecutorContext) |
#### Returns
[`Target`](/reference/core-api/devkit/documents/Target)