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
|
||||
|
||||
▸ **extractLayoutDirectory**(`directory`): `Object`
|
||||
▸ **extractLayoutDirectory**(`directory?`): `Object`
|
||||
|
||||
Experimental
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :---------- | :------- |
|
||||
| `directory` | `string` |
|
||||
| :----------- | :------- |
|
||||
| `directory?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Object`
|
||||
|
||||
| Name | Type |
|
||||
| :----------------- | :------- |
|
||||
| `layoutDirectory` | `string` |
|
||||
| `projectDirectory` | `string` |
|
||||
| :------------------ | :----------------- |
|
||||
| `layoutDirectory` | `string` \| `null` |
|
||||
| `projectDirectory?` | `string` |
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports';
|
||||
import { getWorkspaceLayout } from './get-workspace-layout';
|
||||
import {
|
||||
getWorkspaceLayout,
|
||||
extractLayoutDirectory,
|
||||
} from './get-workspace-layout';
|
||||
|
||||
describe('getWorkspaceLayout', () => {
|
||||
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
|
||||
*/
|
||||
export function extractLayoutDirectory(directory: string): {
|
||||
layoutDirectory: string;
|
||||
projectDirectory: string;
|
||||
export function extractLayoutDirectory(directory?: string): {
|
||||
layoutDirectory: string | null;
|
||||
projectDirectory?: string;
|
||||
} {
|
||||
if (directory) {
|
||||
directory = directory.startsWith('/') ? directory.substring(1) : directory;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user