48
49
export function readRawMapping<T>(file: string): Promise<T> {
50
>
return fs.promises.readFile(FileAccess.asFileUri(`vs/workbench/services/keybinding/test/node/${file}.js`).fsPath).then((buff) => {
keyboardMapperTestUtils.ts
51
>
const contents = buff.toString();
52
>
const func = new Function('define', contents);// CodeQL [SM01632] This is used in tests and we read the files as JS to avoid slowing down TS compilation
53
>
let rawMappings: T | null = null;
54
>
func(function (value: T) {
55
>
rawMappings = value;
56
>
});
57
>
return rawMappings!;
58
>
});
59
>
}
60
61
export function assertMapping(writeFileIfDifferent: boolean, mapper: IKeyboardMapper, file: string): Promise<void> {