Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Durdin <[email protected]>
  • Loading branch information
srl295 and mcdurdin authored Dec 2, 2024
1 parent 75d172a commit 48da8fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion developer/src/common/web/utils/src/common-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class CommonTypesMessages {
static ERROR_ImportInvalidBase = SevError | 0x0002;
static Error_ImportInvalidBase = (o: { base: string, path: string, subtag: string }) =>
m(this.ERROR_ImportInvalidBase,
`Import element with base ${def(o.base)} is unsupported. Only ${constants.cldr_import_base} or empty (for local) is supported.`);
`Import element with base ${def(o.base)} is unsupported. Only ${constants.cldr_import_base} or empty (for local) are supported.`);

static ERROR_ImportInvalidPath = SevError | 0x0003;
static Error_ImportInvalidPath = (o: { base: string, path: string, subtag: string }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ export class LDMLKeyboardXMLSourceFileReader {
// try each of the local imports paths
for (const localPath of this.options.localImportsPaths) {
const importPath = this.callbacks.resolveFilename(localPath, path);
const data = this.callbacks.loadFile(importPath);
if (data) return data;
if(this.callbacks.fs.existsSync(importPath)) {
return this.callbacks.loadFile(importPath);
}
}
return null; // was not able to load from any of the paths
}
Expand Down Expand Up @@ -216,6 +217,7 @@ export class LDMLKeyboardXMLSourceFileReader {
*/
private resolveOneImport(obj: any, subtag: string, asImport: LKImport, implied? : boolean) : boolean {
const { base, path } = asImport;
// If base is not an empty string (or null/undefined), then it must be 'cldr'
if (base && base !== constants.cldr_import_base) {
this.callbacks.reportMessage(CommonTypesMessages.Error_ImportInvalidBase({base, path, subtag}));
return false;
Expand Down Expand Up @@ -262,7 +264,7 @@ export class LDMLKeyboardXMLSourceFileReader {
// mark all children as an implied import
subsubval.forEach(o => o[ImportStatus.impliedImport] = basePath);
}
if (!base) {
if (base !== constants.cldr_import_base) {
subsubval.forEach(o => o[ImportStatus.localImport] = path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface LKImport {
/**
* import base, currently `cldr` is supported
*/
base?: string;
base?: 'cldr';
/**
* path to imported resource, of the form `45/*.xml`
*/
Expand Down

0 comments on commit 48da8fd

Please sign in to comment.