fix: es6 module loading (#1036)

The modification helps to handle correctly the ES6 default exports.
The firmware upgrade run correctly in the electron version and
kboot-firmware-upgrade.ts script
This commit is contained in:
Róbert Kiss
2019-09-09 22:14:34 +02:00
committed by László Monda
parent df040fb78e
commit d0626405a9

View File

@@ -1,7 +1,7 @@
import { Device, devices } from 'node-hid'; import { Device, devices } from 'node-hid';
import { readFile } from 'fs-extra'; import { readFile } from 'fs-extra';
import { EOL } from 'os'; import { EOL } from 'os';
import MemoryMap from 'nrf-intel-hex'; import * as MemoryMap from 'nrf-intel-hex';
import { LogService } from 'uhk-common'; import { LogService } from 'uhk-common';
import { Constants, UsbCommand } from './constants'; import { Constants, UsbCommand } from './constants';
@@ -126,7 +126,9 @@ export const getFileContentAsync = async (filePath: string): Promise<Array<strin
export const readBootloaderFirmwareFromHexFileAsync = async (hexFilePath: string): Promise<Map<any, any>> => { export const readBootloaderFirmwareFromHexFileAsync = async (hexFilePath: string): Promise<Map<any, any>> => {
const fileContent = await readFile(hexFilePath, { encoding: 'utf8' }); const fileContent = await readFile(hexFilePath, { encoding: 'utf8' });
const memoryMap = MemoryMap.fromHex(fileContent); const fromHex = MemoryMap.fromHex ? MemoryMap.fromHex : MemoryMap.default.fromHex;
const memoryMap = fromHex(fileContent);
return memoryMap; return memoryMap;
}; };