Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('search lg custom function', () => {
expect(result.length).toEqual(2);
expect(result[0]).toEqual('foo.bar');
expect(result[1]).toEqual('foo.cool');
const lgFilesWithoutOptions = [{ id: 'test.en-us' }];
const result1 = searchLgCustomFunction(lgFilesWithoutOptions as LgFile[]);
expect(result1.length).toEqual(0);
});

it('should return custom functions with namespace', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ const ExportsKey = '@exports';
export const searchLgCustomFunction = (lgFiles: LgFile[]): string[] => {
const customFunctions = lgFiles.reduce((result: string[], lgFile) => {
const { options } = lgFile;
const exports = extractOptionByKey(ExportsKey, options);
let namespace = extractOptionByKey(NamespaceKey, options);
if (!namespace) namespace = lgFile.id; //if namespace doesn't exist, use file name
const funcList = exports.split(',');
funcList.forEach((func) => {
if (func) {
result.push(`${namespace}.${func.trim()}`);
}
});

if (options?.length) {
const exports = extractOptionByKey(ExportsKey, options);
let namespace = extractOptionByKey(NamespaceKey, options);
if (!namespace) namespace = lgFile.id; //if namespace doesn't exist, use file name
const funcList = exports.split(',');
funcList.forEach((func) => {
if (func) {
result.push(`${namespace}.${func.trim()}`);
}
});
}
return result;
}, []);
return customFunctions;
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/shared/src/types/indexers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export interface LgFile {
content: string;
diagnostics: Diagnostic[];
templates: LgTemplate[];
options: string[];
options?: string[];
}

export interface Skill {
Expand Down