patch: updated webpack config for EP

This commit is contained in:
Peter Makra 2022-04-01 13:59:01 +02:00
parent bed126506f
commit a4534be03b

View File

@ -15,7 +15,7 @@
*/ */
import * as CopyPlugin from 'copy-webpack-plugin'; import * as CopyPlugin from 'copy-webpack-plugin';
import { readdirSync } from 'fs'; import { readdirSync, existsSync } from 'fs';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as os from 'os'; import * as os from 'os';
import outdent from 'outdent'; import outdent from 'outdent';
@ -78,15 +78,22 @@ function renameNodeModules(resourcePath: string) {
} }
function findLzmaNativeBindingsFolder(): string { function findLzmaNativeBindingsFolder(): string {
const files = readdirSync(path.join('node_modules', 'lzma-native')); const lzmaModuleBasePath = path.join('node_modules', 'lzma-native')
const bindingsFolder = files.find( const files = readdirSync(lzmaModuleBasePath);
let bindingsFolder = files.find(
(f) => (f) =>
f.startsWith('binding-') && f.startsWith('binding-') &&
f.endsWith(env.npm_config_target_arch || os.arch()), f.endsWith(env.npm_config_target_arch || os.arch()),
); );
if (bindingsFolder === undefined) { if (bindingsFolder === undefined) {
// later version of lzma-native changed the build output folder to ./build/Release
const buildOutputPath = path.join('build', 'Release');
if (existsSync(path.join(lzmaModuleBasePath, buildOutputPath))) {
bindingsFolder = buildOutputPath
} else {
throw new Error('Could not find lzma_native binding'); throw new Error('Could not find lzma_native binding');
} }
}
return bindingsFolder; return bindingsFolder;
} }