Skip to content

Commit

Permalink
fix(storybook): optional chain .length in utils (#18001)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini authored Jul 7, 2023
1 parent 3fdc66d commit 3edbe49
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export function getTsConfigPath(
const { root, projectType } = readProjectConfiguration(tree, projectName);
return join(
root,
path && path.length > 0
path?.length > 0
? path
: projectType === 'application'
? 'tsconfig.app.json'
Expand Down Expand Up @@ -595,7 +595,7 @@ export function addBuildStorybookToCacheableOperations(tree: Tree) {
}

export function projectIsRootProjectInStandaloneWorkspace(projectRoot: string) {
return relative(workspaceRoot, projectRoot).length === 0;
return relative(workspaceRoot, projectRoot)?.length === 0;
}

export function workspaceHasRootProject(tree: Tree) {
Expand Down Expand Up @@ -682,14 +682,14 @@ export function renameAndMoveOldTsConfig(
json.extends = json.extends.replace('../', './');
}

for (let i = 0; i < json.files.length; i++) {
for (let i = 0; i < json.files?.length; i++) {
// drop one level of nesting
if (json.files[i].startsWith('../../../')) {
json.files[i] = json.files[i].replace('../../../', '../../');
}
}

for (let i = 0; i < json.include.length; i++) {
for (let i = 0; i < json.include?.length; i++) {
if (json.include[i].startsWith('../')) {
json.include[i] = json.include[i].replace('../', '');
}
Expand All @@ -702,7 +702,7 @@ export function renameAndMoveOldTsConfig(
}
}

for (let i = 0; i < json.exclude.length; i++) {
for (let i = 0; i < json.exclude?.length; i++) {
if (json.exclude[i].startsWith('../')) {
json.exclude[i] = json.exclude[i].replace('../', 'src/');
}
Expand All @@ -719,7 +719,7 @@ export function renameAndMoveOldTsConfig(

const projectTsConfig = joinPathFragments(projectRoot, 'tsconfig.json');
updateJson(tree, projectTsConfig, (json) => {
for (let i = 0; i < json.references.length; i++) {
for (let i = 0; i < json.references?.length; i++) {
if (json.references[i].path === './.storybook/tsconfig.json') {
json.references[i].path = './tsconfig.storybook.json';
break;
Expand Down

1 comment on commit 3edbe49

@vercel
Copy link

@vercel vercel bot commented on 3edbe49 Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.