Skip to content

Commit

Permalink
fix(storybook): optional chain .length in utils (#18001)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3edbe49)
  • Loading branch information
mandarini authored and FrozenPandaz committed Jul 7, 2023
1 parent 0e15bea commit b1a8917
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

0 comments on commit b1a8917

Please sign in to comment.