Skip to content

Commit

Permalink
scripts: fix the comparison of package references (#12122)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Maréchal <paul.marechal@ericsson.com>
  • Loading branch information
inlann and paul-marechal authored Jan 31, 2023
1 parent fda6e9c commit 6091474
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion dev-packages/private-eslint-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@
"include": [
"rules"
],
"references": []
"references": [
{
"path": "../../packages/core"
},
{
"path": "../private-re-exports"
}
]
}
6 changes: 6 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
"references": [
{
"path": "../../dev-packages/application-package"
},
{
"path": "../../dev-packages/private-re-exports"
},
{
"path": "../../dev-packages/request"
}
]
}
3 changes: 3 additions & 0 deletions packages/editor-preview/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
{
"path": "../editor"
},
{
"path": "../navigator"
}
]
}
4 changes: 3 additions & 1 deletion scripts/compile-references.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ async function configureTypeScriptReferences(targetPackage, expectedReferences)
/** @type {string[]} */
const currentReferences = (tsconfigJson['references'] || []).map(reference => reference.path);
// Compare both arrays: if an element is not the same we need to rewrite.
needRewrite = needRewrite || currentReferences.some((reference, index) => expectedReferences[index] !== reference);
needRewrite = needRewrite
|| currentReferences.length !== expectedReferences.length
|| currentReferences.some((reference, index) => expectedReferences[index] !== reference);
if (needRewrite) {
tsconfigJson.references = expectedReferences.map(path => ({ path }));
const content = JSON.stringify(tsconfigJson, undefined, 2);
Expand Down

0 comments on commit 6091474

Please sign in to comment.