From d4eaaefe306f8714ed1059eb24483590e992dea1 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 9 Jan 2023 10:16:13 +0000 Subject: [PATCH] fix(docs-infra): correctly read example type (#48665) Prior to this change the universal example was broken as the example type was not retrieved correctly in bazel which caused the `_renameFile` method to be called with incorrect context. Closes #48664 PR Close #48665 --- aio/tools/example-zipper/exampleZipper.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aio/tools/example-zipper/exampleZipper.mjs b/aio/tools/example-zipper/exampleZipper.mjs index bb526de1834..7125f3dda39 100644 --- a/aio/tools/example-zipper/exampleZipper.mjs +++ b/aio/tools/example-zipper/exampleZipper.mjs @@ -57,8 +57,9 @@ export class ExampleZipper { return archive; } - _getExampleType(sourceFolder) { - const filePath = path.join(sourceFolder, EXAMPLE_CONFIG_NAME); + _getExampleType(exampleDirName) { + const filePath = path.join(exampleDirName, EXAMPLE_CONFIG_NAME); + try { return this._loadJson(filePath).projectType || 'cli'; } catch (err) { // empty file, so it is cli @@ -89,7 +90,6 @@ export class ExampleZipper { const jsonFileName = configFileName.replace(/^.*[\\\/]/, ''); let relativeDirName = path.basename(sourceDirName); let exampleZipName; - const exampleType = this._getExampleType(path.join(sourceDirName, relativeDirName)); if (relativeDirName.indexOf('/') !== -1) { // Special example exampleZipName = relativeDirName.split('/').join('-'); } else { @@ -97,6 +97,7 @@ export class ExampleZipper { } const exampleDirName = path.dirname(configFileName); + const exampleType = this._getExampleType(exampleDirName); const outputFileName = path.join(outputDirName, exampleZipName + '.zip'); let defaultIncludes = ['**/*.ts', '**/*.js', '**/*.es6', '**/*.css', '**/*.html', '**/*.md', '**/*.json', '**/*.png', '**/*.svg']; let alwaysIncludes = [