当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript deepAssign.deepAssign函数代码示例

本文整理汇总了TypeScript中read-config-file/out/deepAssign.deepAssign函数的典型用法代码示例。如果您正苦于以下问题:TypeScript deepAssign函数的具体用法?TypeScript deepAssign怎么用?TypeScript deepAssign使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了deepAssign函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getConfig

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<Configuration> {
  const configRequest: ReadConfigRequest = {packageKey: "build", configFilename: "electron-builder", projectDir, packageMetadata}
  const configAndEffectiveFile = await _getConfig<Configuration>(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")
  }

  let extendsSpec = config.extends
  if (extendsSpec == null && extendsSpec !== null) {
    const devDependencies = (await packageMetadata.value || {}).devDependencies
    if (devDependencies != null) {
      if ("react-scripts" in devDependencies) {
        extendsSpec = "react-cra"
        config.extends = extendsSpec
      }
      else if ("electron-webpack" in devDependencies) {
        extendsSpec = "electron-webpack/electron-builder.yml"
        config.extends = extendsSpec
      }
    }
  }

  if (extendsSpec == null) {
    return deepAssign(getDefaultConfig(), config)
  }

  let parentConfig: Configuration | null
  if (extendsSpec === "react-cra") {
    parentConfig = await reactCra(projectDir)
    log.info({preset: extendsSpec}, "loaded parent configuration")
  }
  else {
    const parentConfigAndEffectiveFile = await loadParentConfig<Configuration>(configRequest, extendsSpec)
    log.info({file: parentConfigAndEffectiveFile.configFile}, "loaded parent configuration")
    parentConfig = parentConfigAndEffectiveFile.result
  }

  // electron-webpack and electrify client config - want to exclude some files
  // we add client files configuration to main parent file matcher
  if (parentConfig.files != null && config.files != null && (Array.isArray(config.files) || typeof config.files === "string") && Array.isArray(parentConfig.files) && parentConfig.files.length > 0) {
    const mainFileSet = parentConfig.files[0]
    if (typeof mainFileSet === "object" && (mainFileSet.from == null || mainFileSet.from === ".")) {
      mainFileSet.filter = asArray(mainFileSet.filter)
      mainFileSet.filter.push(...asArray(config.files as any))
      delete (config as any).files
    }
  }

  return deepAssign(getDefaultConfig(), parentConfig, config)
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:55,代码来源:config.ts

示例2: assertPack

export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions = {}): Promise<void> {
  if (checkOptions.signed) {
    packagerOptions = signed(packagerOptions)
  }
  if (checkOptions.signedWin) {
    packagerOptions.cscLink = WIN_CSC_LINK
    packagerOptions.cscKeyPassword = ""
  }
  else if (packagerOptions.cscLink == null) {
    packagerOptions = deepAssign({}, packagerOptions, {config: {mac: {identity: null}}})
  }

  const projectDirCreated = checkOptions.projectDirCreated
  let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName)
  // const isDoNotUseTempDir = platform === "darwin"
  const customTmpDir = process.env.TEST_APP_TMP_DIR
  const tmpDir = new TmpDir()
  // non-macOS test uses the same dir as macOS test, but we cannot share node_modules (because tests executed in parallel)
  const dir = customTmpDir == null ? await tmpDir.createTempDir() : path.resolve(customTmpDir)
  if (customTmpDir != null) {
    await emptyDir(dir)
    log(`Custom temp dir used: ${customTmpDir}`)
  }

  await copyDir(projectDir, dir, it => {
    const basename = path.basename(it)
    return basename !== OUT_DIR_NAME && basename !== "node_modules" && !basename.startsWith(".")
  }, null, it => path.basename(it) !== "package.json")
  projectDir = dir

  await executeFinally((async () => {
    if (projectDirCreated != null) {
      await projectDirCreated(projectDir, tmpDir)
      if (checkOptions.installDepsBefore) {
        // bin links required (e.g. for node-pre-gyp - if package refers to it in the install script)
        await spawn(process.platform === "win32" ? "yarn.cmd" : "yarn", ["install", "--production", "--no-lockfile"], {
          cwd: projectDir,
        })
      }
    }

    const {packager, outDir} = await packAndCheck({projectDir, ...packagerOptions}, checkOptions)

    if (checkOptions.packed != null) {
      function base(platform: Platform, arch?: Arch): string {
        return path.join(outDir, `${platform.buildConfigurationKey}${getArchSuffix(arch == null ? Arch.x64 : arch)}${platform === Platform.MAC ? "" : "-unpacked"}`)
      }

      await checkOptions.packed({
        projectDir,
        outDir,
        getResources: (platform, arch) => path.join(base(platform, arch), "resources"),
        getContent: platform => base(platform),
        packager,
        tmpDir,
      })
    }
  })(), () => tmpDir.cleanup())
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:59,代码来源:packTester.ts

示例3: pack

  async pack(outDir: string, arch: Arch, targets: Array<Target>, taskManager: AsyncTaskManager): Promise<any> {
    let nonMasPromise: Promise<any> | null = null

    const hasMas = targets.length !== 0 && targets.some(it => it.name === "mas" || it.name === "mas-dev")
    const prepackaged = this.packagerOptions.prepackaged

    if (!hasMas || targets.length > 1) {
      const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${this.appInfo.productFilename}.app`) : prepackaged
      nonMasPromise = (prepackaged ? BluebirdPromise.resolve() : this.doPack(outDir, path.dirname(appPath), this.platform.nodeName, arch, this.platformSpecificBuildOptions, targets))
        .then(() => this.sign(appPath, null, null))
        .then(() => this.packageInDistributableFormat(appPath, Arch.x64, targets, taskManager))
    }

    for (const target of targets) {
      const targetName = target.name
      if (!(targetName === "mas" || targetName === "mas-dev")) {
        continue
      }

      const masBuildOptions = deepAssign({}, this.platformSpecificBuildOptions, (this.config as any).mas)
      if (targetName === "mas-dev") {
        deepAssign(masBuildOptions, (this.config as any)[targetName], {
          type: "development",
        })
      }

      const targetOutDir = path.join(outDir, targetName)
      if (prepackaged == null) {
        await this.doPack(outDir, targetOutDir, "mas", arch, masBuildOptions, [target])
        await this.sign(path.join(targetOutDir, `${this.appInfo.productFilename}.app`), targetOutDir, masBuildOptions)
      }
      else {
        await this.sign(prepackaged, targetOutDir, masBuildOptions)
      }
    }

    if (nonMasPromise != null) {
      await nonMasPromise
    }
  }
开发者ID:jwheare,项目名称:electron-builder,代码行数:40,代码来源:macPackager.ts

示例4: modifyMainPackageJson

async function modifyMainPackageJson(file: string, extraMetadata: any) {
  const mainPackageData = await readJson(file)
  if (extraMetadata != null) {
    deepAssign(mainPackageData, extraMetadata)
  }

  // https://github.com/electron-userland/electron-builder/issues/1212
  const serializedDataIfChanged = cleanupPackageJson(mainPackageData, true)
  if (serializedDataIfChanged != null) {
    return serializedDataIfChanged
  }
  else if (extraMetadata != null) {
    return JSON.stringify(mainPackageData, null, 2)
  }
  return null
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:16,代码来源:fileTransformer.ts

示例5: mergePublish

// https://github.com/electron-userland/electron-builder/issues/1847
function mergePublish(config: Configuration, configFromOptions: Configuration) {
  // if config from disk doesn't have publish (or object), no need to handle, it will be simply merged by deepAssign
  const publish = Array.isArray(config.publish) ? configFromOptions.publish : null
  if (publish != null) {
    delete (configFromOptions as any).publish
  }

  deepAssign(config, configFromOptions)

  if (publish == null) {
    return
  }

  const listOnDisk = config.publish as Array<any>
  if (listOnDisk.length === 0) {
    config.publish = publish
  }
  else {
    // apply to first
    Object.assign(listOnDisk[0], publish)
  }
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:23,代码来源:config.ts

示例6: normalizeOptions


//.........这里部分代码省略.........
  if (args.linux != null) {
    processTargets(Platform.LINUX, args.linux)
  }

  if (args.win != null) {
    processTargets(Platform.WINDOWS, args.win)
  }

  if (targets.size === 0) {
    if (args.platform == null && args.arch == null) {
      processTargets(Platform.current(), [])
    }
    else {
      targets = createTargets(normalizePlatforms(args.platform), args.dir ? DIR_TARGET : null, args.arch)
    }
  }

  const result = {...args}
  result.targets = targets

  delete result.dir
  delete result.mac
  delete result.linux
  delete result.win
  delete result.platform
  delete result.arch

  const r = result as any
  delete r.em

  delete r.m
  delete r.o
  delete r.l
  delete r.w
  delete r.windows
  delete r.macos
  delete r.$0
  delete r._
  delete r.version
  delete r.help
  delete r.c

  delete result.ia32
  delete result.x64
  delete result.armv7l

  if (result.project != null && result.projectDir == null) {
    result.projectDir = result.project
  }
  delete result.project

  let config = result.config
  const extraMetadata = result.extraMetadata
  delete result.extraMetadata

  // config is array when combining dot-notation values with a config file value (#2016)
  if (Array.isArray(config)) {
    const newConfig: Configuration = {}

    for (const configItem of config) {
      if (typeof configItem === "object") {
        deepAssign(newConfig, configItem)
      }
      else if (typeof configItem === "string") {
        newConfig.extends = configItem
      }
    }

    config = newConfig
    result.config = newConfig
  }

  if (extraMetadata != null) {
    if (typeof config === "string") {
      // transform to object and specify path to config as extends
      config = {
        extends: config,
        extraMetadata,
      };
      (result as any).config = config
    }
    else if (config == null) {
      config = {};
      (result as any).config = config
    }
    (config as any).extraMetadata = extraMetadata
  }

  if (config != null && typeof config !== "string") {
    if (config.extraMetadata != null) {
      coerceTypes(config.extraMetadata)
    }
    if (config.mac != null) {
      // ability to disable code sign using -c.mac.identity=null
      coerceValue(config.mac, "identity")
    }
  }

  return result as BuildOptions
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:101,代码来源:builder.ts


注:本文中的read-config-file/out/deepAssign.deepAssign函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。