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


TypeScript deepAssign.deepAssign函数代码示例

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


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

示例1: 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:yuya-oc,项目名称:electron-builder,代码行数:40,代码来源:macPackager.ts

示例2: 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:djpereira,项目名称:electron-builder,代码行数:16,代码来源:fileTransformer.ts

示例3: getConfig

export async function getConfig(projectDir: string, configPath: string | null, packageMetadata: any | null, configFromOptions: Config | null | undefined): Promise<Config> {
  let fileOrPackageConfig
  if (configPath == null) {
    fileOrPackageConfig = await loadConfig(projectDir, packageMetadata)
  }
  else {
    fileOrPackageConfig = await readConfig<Config>(path.resolve(projectDir, configPath), projectDir, log)
  }

  const config: Config = deepAssign(fileOrPackageConfig == null ? Object.create(null) : fileOrPackageConfig, configFromOptions)

  let extendsSpec = config.extends
  if (extendsSpec == null && extendsSpec !== null && packageMetadata != null) {
    const devDependencies = packageMetadata.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 config
  }

  let parentConfig: Config | null
  if (extendsSpec === "react-cra") {
    parentConfig = await reactCra(projectDir)
  }
  else {
    let spec = extendsSpec
    let isFileSpec: boolean | undefined
    if (spec.startsWith("file:")) {
      spec = spec.substring("file:".length)
      isFileSpec = true
    }

    parentConfig = await orNullIfFileNotExist(readConfig(path.resolve(projectDir, spec), projectDir, log))
    if (parentConfig == null && isFileSpec !== true) {
      let resolved: string | null = null
      try {
        resolved = require.resolve(spec)
      }
      catch (e) {
        // ignore
      }

      if (resolved != null) {
        parentConfig = await readConfig(resolved, projectDir, log)
      }
    }

    if (parentConfig == null) {
      throw new Error(`Cannot find parent config file: ${spec}`)
    }
  }

  // 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(parentConfig, config)
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:75,代码来源:config.ts

示例4: 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
  let dirToDelete: string | null = null
  // 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 ? getTempFile() : path.resolve(customTmpDir)
  if (customTmpDir == null) {
    dirToDelete = dir
  }
  else {
    log(`Custom temp dir used: ${customTmpDir}`)
  }
  await emptyDir(dir)
  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)
      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,
      })
    }
  })(), async () => {
    if (dirToDelete != null) {
      try {
        await remove(dirToDelete)
      }
      catch (e) {
        console.warn(`Cannot delete temporary directory ${dirToDelete}: ${(e.stack || e)}`)
      }
    }
  })
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:69,代码来源:packTester.ts


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