Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function getElectronWebpackConfiguration(context: ConfigurationRequest): Promise {
const result = await getConfig({
packageKey: "electronWebpack",
configFilename: "electron-webpack",
projectDir: context.projectDir,
packageMetadata: context.packageMetadata
})
const configuration: ElectronWebpackConfiguration = result == null || result.result == null ? {} : result.result
if (configuration.staticSourceDirectory == null) {
configuration.staticSourceDirectory = "static"
}
if (configuration.commonDistDirectory == null) {
configuration.commonDistDirectory = "dist"
}
if (configuration.commonSourceDirectory == null) {
configuration.commonSourceDirectory = getDefaultRelativeSystemDependentCommonSource()
}
configuration.commonDistDirectory = path.resolve(context.projectDir, configuration.commonDistDirectory)
async function computeTitle(configurator: WebpackConfigurator): Promise {
const titleFromOptions = configurator.electronWebpackConfiguration.title
if (titleFromOptions == null || titleFromOptions === false) {
return null
}
if (titleFromOptions !== true) {
return titleFromOptions
}
let title: string | null | undefined = (configurator.metadata as any).productName
if (title == null) {
const electronBuilderConfig = await getConfig({
packageKey: "build",
configFilename: "electron-builder",
projectDir: configurator.projectDir,
packageMetadata: new Lazy(() => Promise.resolve(configurator.metadata))
})
if (electronBuilderConfig != null) {
title = electronBuilderConfig.result.productName
}
}
if (title == null) {
title = configurator.metadata.name
}
return title
}
export async function getConfig(projectDir: string,
configPath: string | null,
configFromOptions: Configuration | null | undefined,
packageMetadata: Lazy<{ [key: string]: any } | null> = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))): Promise {
const configRequest: ReadConfigRequest = {packageKey: "build", configFilename: "electron-builder", projectDir, packageMetadata}
const configAndEffectiveFile = await _getConfig(configRequest, configPath)
const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result
if (configFromOptions != null) {
mergePublish(config, configFromOptions)
}
if (configAndEffectiveFile != null) {
log.info({file: configAndEffectiveFile.configFile == null ? 'package.json ("build" field)' : configAndEffectiveFile.configFile}, "loaded configuration")
}
if (config.extends == null && config.extends !== null) {
const metadata = await packageMetadata.value || {}
const devDependencies = metadata.devDependencies
const dependencies = metadata.dependencies
if ((dependencies != null && "react-scripts" in dependencies) || (devDependencies != null && "react-scripts" in devDependencies)) {
config.extends = "react-cra"
}