Skip to content

Commit

Permalink
feat(devkit): add method to read installed Nx version
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Feb 21, 2023
1 parent f8d4995 commit cfeb04c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/generated/packages/devkit/documents/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,16 @@ Prefixes project name with npm scope

---

### getInstalledNxVersion

**getInstalledNxVersion**(): `string` \| `null`

#### Returns

`string` \| `null`

---

### getNpmPackageSharedConfig

**getNpmPackageSharedConfig**(`pkgName`, `version`): [`SharedLibraryConfig`](../../devkit/documents/nrwl_devkit#sharedlibraryconfig) \| `undefined`
Expand Down Expand Up @@ -1781,6 +1791,22 @@ Synchronously reads the latest cached copy of the workspace's ProjectGraph.

---

### readInstalledPackageVersion

**readInstalledPackageVersion**(`pkg`): `string` \| `null`

#### Parameters

| Name | Type |
| :---- | :------- |
| `pkg` | `string` |

#### Returns

`string` \| `null`

---

### readJson

**readJson**<`T`\>(`tree`, `path`, `options?`): `T`
Expand Down
1 change: 1 addition & 0 deletions packages/devkit/nx-reexports-pre16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export {
addDependenciesToPackageJson,
ensurePackage,
removeDependenciesFromPackageJson,
NX_VERSION,
} from './src/utils/package-json';

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/devkit/src/utils/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,5 @@ function getPackageVersion(pkg: string): undefined | string {
return undefined;
}
}

export const NX_VERSION = getPackageVersion('nx');

0 comments on commit cfeb04c

Please sign in to comment.