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


TypeScript electron-builder-util.asArray函数代码示例

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


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

示例1: installOrRebuild

export async function installOrRebuild(config: Config, appDir: string, electronVersion: string, platform: string, arch: string, forceInstall: boolean = false) {
  const args = asArray(config.npmArgs)
  if (forceInstall || !(await exists(path.join(appDir, "node_modules")))) {
    await installDependencies(appDir, electronVersion, platform, arch, args, !config.npmSkipBuildFromSource)
  }
  else {
    await rebuild(appDir, electronVersion, platform, arch, args, !config.npmSkipBuildFromSource)
  }
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:9,代码来源:yarn.ts

示例2: asArray

 appPlist.CFBundleURLTypes = protocols.map(protocol => {
   const schemes = asArray(protocol.schemes)
   if (schemes.length === 0) {
     throw new Error(`Protocol "${protocol.name}": must be at least one scheme specified`)
   }
   return {
     CFBundleURLName: protocol.name,
     CFBundleTypeRole: protocol.role || "Editor",
     CFBundleURLSchemes: schemes.slice()
   }
 })
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:11,代码来源:mac.ts

示例3: installOrRebuild

export async function installOrRebuild(config: Config, appDir: string, options: RebuildOptions, forceInstall: boolean = false) {
  const effectiveOptions = {
    buildFromSource: config.buildDependenciesFromSource === true,
    additionalArgs: asArray(config.npmArgs), ...options
  }

  if (forceInstall || !(await exists(path.join(appDir, "node_modules")))) {
    await installDependencies(appDir, effectiveOptions)
  }
  else {
    await rebuild(appDir, effectiveOptions)
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:13,代码来源:yarn.ts

示例4: 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

示例5: createMacApp

export async function createMacApp(packager: PlatformPackager<any>, appOutDir: string, asarIntegrity: AsarIntegrity | null) {
  const appInfo = packager.appInfo
  const appFilename = appInfo.productFilename

  const contentsPath = path.join(appOutDir, packager.electronDistMacOsAppName, "Contents")
  const frameworksPath = path.join(contentsPath, "Frameworks")

  const appPlistFilename = path.join(contentsPath, "Info.plist")
  const helperPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper.app`, "Contents", "Info.plist")
  const helperEHPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper EH.app`, "Contents", "Info.plist")
  const helperNPPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper NP.app`, "Contents", "Info.plist")

  const buildMetadata = packager.config!
  const fileContents: Array<string> = await BluebirdPromise.map([appPlistFilename, helperPlistFilename, helperEHPlistFilename, helperNPPlistFilename, (buildMetadata as any)["extend-info"]], it => it == null ? it : readFile(it, "utf8"))
  const appPlist = parsePlist(fileContents[0])
  const helperPlist = parsePlist(fileContents[1])
  const helperEHPlist = parsePlist(fileContents[2])
  const helperNPPlist = parsePlist(fileContents[3])

  // If an extend-info file was supplied, copy its contents in first
  if (fileContents[4] != null) {
    Object.assign(appPlist, parsePlist(fileContents[4]))
  }

  const macOptions = buildMetadata.mac
  if (macOptions != null && macOptions.extendInfo != null) {
    Object.assign(appPlist, macOptions.extendInfo)
  }

  const appBundleIdentifier = filterCFBundleIdentifier(appInfo.id)

  const oldHelperBundleId = (buildMetadata as any)["helper-bundle-id"]
  if (oldHelperBundleId != null) {
    warn("build.helper-bundle-id is deprecated, please set as build.mac.helperBundleId")
  }
  const helperBundleIdentifier = filterCFBundleIdentifier(packager.platformSpecificBuildOptions.helperBundleId || oldHelperBundleId || `${appBundleIdentifier}.helper`)

  const icon = await packager.getIconPath()
  const oldIcon = appPlist.CFBundleIconFile
  if (icon != null) {
    appPlist.CFBundleIconFile = `${appFilename}.icns`
  }

  appPlist.CFBundleDisplayName = appInfo.productName
  appPlist.CFBundleIdentifier = appBundleIdentifier
  appPlist.CFBundleName = appInfo.productName

  // https://github.com/electron-userland/electron-builder/issues/1278
  appPlist.CFBundleExecutable = !appFilename.endsWith(" Helper") ? appFilename : appFilename.substring(0, appFilename.length - " Helper".length)

  helperPlist.CFBundleExecutable = `${appFilename} Helper`
  helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
  helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`

  helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
  helperEHPlist.CFBundleDisplayName = `${appInfo.productName} Helper EH`
  helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`

  helperPlist.CFBundleIdentifier = helperBundleIdentifier
  helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
  helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`

  appPlist.CFBundleShortVersionString = appInfo.version
  appPlist.CFBundleVersion = appInfo.buildVersion

  const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))
  if (protocols.length > 0) {
    appPlist.CFBundleURLTypes = protocols.map(protocol => {
      const schemes = asArray(protocol.schemes)
      if (schemes.length === 0) {
        throw new Error(`Protocol "${protocol.name}": must be at least one scheme specified`)
      }
      return {
        CFBundleURLName: protocol.name,
        CFBundleTypeRole: protocol.role || "Editor",
        CFBundleURLSchemes: schemes.slice()
      }
    })
  }

  const resourcesPath = path.join(contentsPath, "Resources")

  const fileAssociations = packager.fileAssociations
  if (fileAssociations.length > 0) {
    appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
      const extensions = asArray(fileAssociation.ext).map(normalizeExt)
      const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)
      let iconFile = appPlist.CFBundleIconFile
      if (customIcon != null) {
        iconFile = path.basename(customIcon)
        await copyOrLinkFile(customIcon, path.join(resourcesPath, iconFile))
      }

      const result = {
        CFBundleTypeExtensions: extensions,
        CFBundleTypeName: fileAssociation.name || extensions[0],
        CFBundleTypeRole: fileAssociation.role || "Editor",
        CFBundleTypeIconFile: iconFile
      } as any

//.........这里部分代码省略.........
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:101,代码来源:mac.ts


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