fix(react): fix creating a react library with cwd (#19721)
This commit is contained in:
parent
f619c80151
commit
85bda9ab8a
@ -404,7 +404,7 @@ function isTTY(): boolean {
|
||||
return !!process.stdout.isTTY && process.env['CI'] !== 'true';
|
||||
}
|
||||
|
||||
function getRelativeCwd(): string {
|
||||
export function getRelativeCwd(): string {
|
||||
return normalizePath(relative(workspaceRoot, getCwd()));
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
Tree,
|
||||
updateJson,
|
||||
} from '@nx/devkit';
|
||||
import { getRelativeCwd } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
||||
|
||||
import { addTsConfigPath } from '@nx/js';
|
||||
|
||||
@ -24,6 +25,7 @@ import { createFiles } from './lib/create-files';
|
||||
import { extractTsConfigBase } from '../../utils/create-ts-config';
|
||||
import { installCommonDependencies } from './lib/install-common-dependencies';
|
||||
import { setDefaults } from './lib/set-defaults';
|
||||
import { relative } from 'path';
|
||||
|
||||
export async function libraryGenerator(host: Tree, schema: Schema) {
|
||||
return await libraryGeneratorInternal(host, {
|
||||
@ -171,9 +173,15 @@ export async function libraryGeneratorInternal(host: Tree, schema: Schema) {
|
||||
}
|
||||
|
||||
if (options.component) {
|
||||
const relativeCwd = getRelativeCwd();
|
||||
const name = joinPathFragments(
|
||||
options.projectRoot,
|
||||
'src/lib',
|
||||
options.fileName
|
||||
);
|
||||
const componentTask = await componentGenerator(host, {
|
||||
nameAndDirectoryFormat: 'as-provided',
|
||||
name: joinPathFragments(options.projectRoot, 'src/lib', options.fileName),
|
||||
name: relativeCwd ? relative(relativeCwd, name) : name,
|
||||
project: options.name,
|
||||
flat: true,
|
||||
style: options.style,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user