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 22, 2023
1 parent f8d4995 commit 8a92cb5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/generated/devkit/nrwl_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ It only uses language primitives and immutable objects

### Utils Variables

- [NX_VERSION](../../devkit/documents/nrwl_devkit#nx_version)
- [appRootPath](../../devkit/documents/nrwl_devkit#approotpath)
- [cacheDir](../../devkit/documents/nrwl_devkit#cachedir)
- [output](../../devkit/documents/nrwl_devkit#output)
Expand Down Expand Up @@ -794,6 +795,12 @@ Implementation of a target of a project that handles multiple projects to be bat

## Utils Variables

### NX_VERSION

**NX_VERSION**: `string`

---

### appRootPath

**appRootPath**: `string` = `workspaceRoot`
Expand Down
7 changes: 7 additions & 0 deletions docs/generated/packages/devkit/documents/nrwl_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ It only uses language primitives and immutable objects

### Utils Variables

- [NX_VERSION](../../devkit/documents/nrwl_devkit#nx_version)
- [appRootPath](../../devkit/documents/nrwl_devkit#approotpath)
- [cacheDir](../../devkit/documents/nrwl_devkit#cachedir)
- [output](../../devkit/documents/nrwl_devkit#output)
Expand Down Expand Up @@ -794,6 +795,12 @@ Implementation of a target of a project that handles multiple projects to be bat

## Utils Variables

### NX_VERSION

**NX_VERSION**: `string`

---

### appRootPath

**appRootPath**: `string` = `workspaceRoot`
Expand Down
1 change: 1 addition & 0 deletions packages/devkit/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export {
addDependenciesToPackageJson,
ensurePackage,
removeDependenciesFromPackageJson,
NX_VERSION,
} from './src/utils/package-json';

/**
Expand Down
5 changes: 5 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,8 @@ function getPackageVersion(pkg: string): undefined | string {
return undefined;
}
}

/**
* @description The version of Nx used by the workspace. Returns null if no version is found.
*/
export const NX_VERSION = getPackageVersion('nx');

0 comments on commit 8a92cb5

Please sign in to comment.