Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rosetta): crashes on outdated tablet files in a package #3119

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/jsii-rosetta/lib/rosetta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { isError } from 'util';

import { allTypeScriptSnippets } from './jsii/assemblies';
import { TargetLanguage } from './languages';
import * as logging from './logging';
import { transformMarkdown } from './markdown/markdown';
import { MarkdownRenderer } from './markdown/markdown-renderer';
import { ReplaceTypeScriptTransform } from './markdown/replace-typescript-transform';
Expand Down Expand Up @@ -109,17 +110,23 @@ export class Rosetta {
* Add an assembly
*
* If a default tablet file is found in the assembly's directory, it will be
* loaded.
* loaded (and assumed to contain a complete list of translated snippets for
* this assembly already).
*
* Otherwise, if live conversion is enabled, the snippets in the assembly
* become available for live translation later. This is necessary because we probably
* need to fixture snippets for successful compilation, and the information
* pacmak sends our way later on is not going to be enough to do that.
*/
public async addAssembly(assembly: spec.Assembly, assemblyDir: string) {
if (await fs.pathExists(path.join(assemblyDir, DEFAULT_TABLET_NAME))) {
await this.loadTabletFromFile(path.join(assemblyDir, DEFAULT_TABLET_NAME));
return;
const defaultTablet = path.join(assemblyDir, DEFAULT_TABLET_NAME);
if (await fs.pathExists(defaultTablet)) {
try {
await this.loadTabletFromFile(defaultTablet);
return;
} catch (e) {
logging.warn(`Error loading ${defaultTablet}: ${e.message}. Skipped.`);
}
}

if (this.options.liveConversion) {
Expand Down