fix(devkit): fix extractLayoutDirectory typescript types to better reflect allowed params and return value (#15339)
This commit is contained in:
parent
2cb241a69f
commit
8274f3419d
@ -1,20 +1,20 @@
|
|||||||
# Function: extractLayoutDirectory
|
# Function: extractLayoutDirectory
|
||||||
|
|
||||||
▸ **extractLayoutDirectory**(`directory`): `Object`
|
▸ **extractLayoutDirectory**(`directory?`): `Object`
|
||||||
|
|
||||||
Experimental
|
Experimental
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :---------- | :------- |
|
| :----------- | :------- |
|
||||||
| `directory` | `string` |
|
| `directory?` | `string` |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Object`
|
`Object`
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :----------------- | :------- |
|
| :------------------ | :----------------- |
|
||||||
| `layoutDirectory` | `string` |
|
| `layoutDirectory` | `string` \| `null` |
|
||||||
| `projectDirectory` | `string` |
|
| `projectDirectory?` | `string` |
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports';
|
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports';
|
||||||
import { getWorkspaceLayout } from './get-workspace-layout';
|
import {
|
||||||
|
getWorkspaceLayout,
|
||||||
|
extractLayoutDirectory,
|
||||||
|
} from './get-workspace-layout';
|
||||||
|
|
||||||
describe('getWorkspaceLayout', () => {
|
describe('getWorkspaceLayout', () => {
|
||||||
it('should return selected values', () => {
|
it('should return selected values', () => {
|
||||||
@ -59,3 +62,24 @@ describe('getWorkspaceLayout', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('extractLayoutDirectory', () => {
|
||||||
|
it('should extract layout directory', () => {
|
||||||
|
expect(extractLayoutDirectory('apps/my-app')).toEqual({
|
||||||
|
layoutDirectory: 'apps',
|
||||||
|
projectDirectory: 'my-app',
|
||||||
|
});
|
||||||
|
expect(extractLayoutDirectory('libs/my-lib')).toEqual({
|
||||||
|
layoutDirectory: 'libs',
|
||||||
|
projectDirectory: 'my-lib',
|
||||||
|
});
|
||||||
|
expect(extractLayoutDirectory('packages/my-package')).toEqual({
|
||||||
|
layoutDirectory: 'packages',
|
||||||
|
projectDirectory: 'my-package',
|
||||||
|
});
|
||||||
|
expect(extractLayoutDirectory(undefined)).toEqual({
|
||||||
|
layoutDirectory: null,
|
||||||
|
projectDirectory: undefined,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -34,9 +34,9 @@ export function getWorkspaceLayout(tree: Tree): {
|
|||||||
/**
|
/**
|
||||||
* Experimental
|
* Experimental
|
||||||
*/
|
*/
|
||||||
export function extractLayoutDirectory(directory: string): {
|
export function extractLayoutDirectory(directory?: string): {
|
||||||
layoutDirectory: string;
|
layoutDirectory: string | null;
|
||||||
projectDirectory: string;
|
projectDirectory?: string;
|
||||||
} {
|
} {
|
||||||
if (directory) {
|
if (directory) {
|
||||||
directory = directory.startsWith('/') ? directory.substring(1) : directory;
|
directory = directory.startsWith('/') ? directory.substring(1) : directory;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user