How to use the read-config-file.getConfig function in read-config-file

To help you get started, we’ve selected a few read-config-file examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-webpack / packages / electron-webpack / src / config.ts View on Github external
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)
github electron-userland / electron-webpack / packages / electron-webpack / src / targets / RendererTarget.ts View on Github external
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
}
github electron-userland / electron-builder / packages / app-builder-lib / src / util / config.ts View on Github external
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"
    }

read-config-file

Read configuration file in various formats:

MIT
Latest version published 6 months ago

Package Health Score

67 / 100
Full package analysis

Similar packages