• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fs-extra-p.emptyDir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: pack

  async pack(outDir: string, arch: string, postAsyncTasks: Array<Promise<any>>): Promise<any> {
    if (arch === "ia32") {
      warn("For windows consider only distributing 64-bit, see https://github.com/electron-userland/electron-builder/issues/359#issuecomment-214851130")
    }

    // we must check icon before pack because electron-packager uses icon and it leads to cryptic error message "spawn wine ENOENT"
    await this.iconPath

    let appOutDir = this.computeAppOutDir(outDir, arch)
    const packOptions = this.computePackOptions(outDir, arch)

    if (!this.options.dist) {
      await this.doPack(packOptions, outDir, appOutDir, arch, this.customBuildOptions)
      return
    }

    const unpackedDir = path.join(outDir, `win${arch === "x64" ? "" : `-${arch}`}-unpacked`)
    const finalAppOut = path.join(unpackedDir, "lib", "net45")
    const installerOut = computeDistOut(outDir, arch)
    log("Removing %s and %s", path.relative(this.projectDir, installerOut), path.relative(this.projectDir, unpackedDir))
    await BluebirdPromise.all([
      this.packApp(packOptions, appOutDir),
      emptyDir(installerOut),
      emptyDir(unpackedDir)
    ])

    await move(appOutDir, finalAppOut)
    appOutDir = finalAppOut

    await this.copyExtraResources(appOutDir, arch, this.customBuildOptions)
    if (this.options.dist) {
      postAsyncTasks.push(this.packageInDistributableFormat(outDir, appOutDir, arch, packOptions))
    }
  }
开发者ID:luningCloud,项目名称:electron-builder,代码行数:34,代码来源:winPackager.ts


示例2: unpack

async function unpack(packager: PlatformPackager<any>, out: string, platform: string, options: any) {
  const dist = packager.config.electronDist
  if (dist == null) {
    const zipPath = (await BluebirdPromise.all<any>([
      downloadElectron(options),
      emptyDir(out)
    ]))[0]

    await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`))
  }
  else {
    const source = packager.getElectronSrcDir(dist)
    const destination = packager.getElectronDestDir(out)
    log(`Copying Electron from "${source}" to "${destination}"`)
    await emptyDir(out)
    await copyDir(source, destination)
  }

  if (platform === "linux") {
    // https://github.com/electron-userland/electron-builder/issues/786
    // fix dir permissions — opposite to extract-zip, 7za creates dir with no-access for other users, but dir must be readable for non-root users
    await BluebirdPromise.all([
      chmod(path.join(out, "locales"), "0755"),
      chmod(path.join(out, "resources"), "0755")
    ])
  }
}
开发者ID:djpereira,项目名称:electron-builder,代码行数:27,代码来源:dirPackager.ts


示例3: build

  async build(arch: Arch, appOutDir: string) {
    if (arch === Arch.ia32) {
      warn("For windows consider only distributing 64-bit, see https://github.com/electron-userland/electron-builder/issues/359#issuecomment-214851130")
    }

    const appInfo = this.packager.appInfo
    const version = appInfo.version
    const archSuffix = getArchSuffix(arch)
    const setupFileName = `${appInfo.productName} Setup ${version}${archSuffix}.exe`

    const installerOutDir = path.join(appOutDir, "..", `win${getArchSuffix(arch)}`)
    await emptyDir(installerOutDir)

    const distOptions = await this.computeEffectiveDistOptions(appOutDir, installerOutDir, setupFileName)
    await createWindowsInstaller(distOptions)
    this.packager.dispatchArtifactCreated(path.join(installerOutDir, setupFileName), `${appInfo.name}-Setup-${version}${archSuffix}.exe`)

    const packagePrefix = `${appInfo.name}-${convertVersion(version)}-`
    this.packager.dispatchArtifactCreated(path.join(installerOutDir, `${packagePrefix}full.nupkg`))
    if (distOptions.remoteReleases != null) {
      this.packager.dispatchArtifactCreated(path.join(installerOutDir, `${packagePrefix}delta.nupkg`))
    }

    this.packager.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
  }
开发者ID:mairanteodoro,项目名称:electron-builder,代码行数:25,代码来源:squirrelWindows.ts


示例4: prepareWine

  async prepareWine(wineDir: string) {
    await emptyDir(wineDir)
    //noinspection SpellCheckingInspection
    const env = Object.assign({}, process.env, {
      WINEDLLOVERRIDES: "winemenubuilder.exe=d",
      WINEPREFIX: wineDir
    })

    await exec("wineboot", ["--init"], {env: env})

    // regedit often doesn't modify correctly
    let systemReg = await readFile(path.join(wineDir, "system.reg"), "utf8")
    systemReg = systemReg.replace('"CSDVersion"="Service Pack 3"', '"CSDVersion"=" "')
    systemReg = systemReg.replace('"CurrentBuildNumber"="2600"', '"CurrentBuildNumber"="10240"')
    systemReg = systemReg.replace('"CurrentVersion"="5.1"', '"CurrentVersion"="10.0"')
    systemReg = systemReg.replace('"ProductName"="Microsoft Windows XP"', '"ProductName"="Microsoft Windows 10"')
    systemReg = systemReg.replace('"CSDVersion"=dword:00000300', '"CSDVersion"=dword:00000000')
    await writeFile(path.join(wineDir, "system.reg"), systemReg)

    // remove links to host OS
    const desktopDir = path.join(this.userDir, "Desktop")
    await BluebirdPromise.all([
      unlinkIfExists(desktopDir),
      unlinkIfExists(path.join(this.userDir, "My Documents")),
      unlinkIfExists(path.join(this.userDir, "My Music")),
      unlinkIfExists(path.join(this.userDir, "My Pictures")),
      unlinkIfExists(path.join(this.userDir, "My Videos")),
    ])

    await ensureDir(desktopDir)
    return env
  }
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:32,代码来源:wine.ts


示例5: pack

  async pack(outDir: string, appOutDir: string, arch: string): Promise<any> {
    // we must check icon before pack because electron-packager uses icon and it leads to cryptic error message "spawn wine ENOENT"
    await this.iconPath

    if (!this.options.dist) {
      return super.pack(outDir, appOutDir, arch)
    }

    const installerOut = computeDistOut(outDir, arch)
    log("Removing %s", installerOut)
    await
      BluebirdPromise.all([
        this.doPack(outDir, appOutDir, arch),
        emptyDir(installerOut)
      ])

    const extraResources = await this.copyExtraResources(appOutDir, arch)
    if (extraResources.length > 0) {
      this.extraNuGetFileSources = BluebirdPromise.map(extraResources, file => {
        return stat(file)
          .then(it => {
            const relativePath = path.relative(appOutDir, file)
            const src = it.isDirectory() ? `${relativePath}${path.sep}**` : relativePath
            return `<file src="${src}" target="lib\\net45\\${relativePath.replace(/\//g, "\\")}"/>`
          })
      })
    }
  }
开发者ID:alatzidis,项目名称:electron-builder,代码行数:28,代码来源:winPackager.ts


示例6: pack

  async pack(outDir: string, arch: string, postAsyncTasks: Array<Promise<any>>): Promise<any> {
    if (arch === "ia32") {
      warn("For windows consider only distributing 64-bit, see https://github.com/electron-userland/electron-builder/issues/359#issuecomment-214851130")
    }

    // we must check icon before pack because electron-packager uses icon and it leads to cryptic error message "spawn wine ENOENT"
    await this.iconPath

    const appOutDir = this.computeAppOutDir(outDir, arch)
    const packOptions = this.computePackOptions(outDir, appOutDir, arch)

    if (!this.options.dist) {
      await this.doPack(packOptions, outDir, appOutDir, arch, this.customBuildOptions)
      return
    }

    const installerOut = this.options.dist ? computeDistOut(outDir, arch) : null
    await BluebirdPromise.all([
      this.packApp(packOptions, appOutDir),
      installerOut == null ? BluebirdPromise.resolve() : emptyDir(installerOut)
    ])

    await this.copyExtraResources(appOutDir, arch, this.customBuildOptions)
    if (this.options.dist) {
      postAsyncTasks.push(this.packageInDistributableFormat(outDir, appOutDir, installerOut!, arch, packOptions))
    }
  }
开发者ID:sethlu,项目名称:electron-builder,代码行数:27,代码来源:winPackager.ts


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


示例8: pack

export async function pack(opts: ElectronPackagerOptions, out: string, platform: string, arch: string, electronVersion: string, initializeApp: () => Promise<any>) {
  const zipPath = (await BluebirdPromise.all<any>([
    downloadElectron(createDownloadOpts(opts, platform, arch, electronVersion)),
    emptyDir(out)
  ]))[0]
  await extract(zipPath, {dir: out})
  await require(supportedPlatforms[platform]).createApp(opts, out, initializeApp)
}
开发者ID:SimplyAhmazing,项目名称:electron-builder,代码行数:8,代码来源:dirPackager.ts


示例9: unpack

async function unpack(packager: PlatformPackager<any>, out: string, platform: string, options: InternalElectronDownloadOptions) {
  let dist: string | null | undefined = packager.config.electronDist
  if (dist != null) {
    const zipFile = `electron-v${options.version}-${platform}-${options.arch}.zip`
    const resolvedDist = path.resolve(packager.projectDir, dist)
    if ((await statOrNull(path.join(resolvedDist, zipFile))) != null) {
      options.cache = resolvedDist
      dist = null
    }
  }

  if (dist == null) {
    const zipPath = (await BluebirdPromise.all<any>([
      packager.info.electronDownloader(options),
      emptyDir(out)
    ]))[0]

    if (process.platform === "darwin" || isEnvTrue(process.env.USE_UNZIP)) {
      // on mac unzip faster than 7za (1.1 sec vs 1.6 see)
      await exec("unzip", ["-oqq", "-d", out, zipPath])
    }
    else {
      await spawn(path7za, debug7zArgs("x").concat(zipPath, "-aoa", `-o${out}`))
      if (platform === "linux") {
        // https://github.com/electron-userland/electron-builder/issues/786
        // fix dir permissions — opposite to extract-zip, 7za creates dir with no-access for other users, but dir must be readable for non-root users
        await BluebirdPromise.all([
          chmod(path.join(out, "locales"), "0755"),
          chmod(path.join(out, "resources"), "0755")
        ])
      }
    }
  }
  else {
    const source = packager.getElectronSrcDir(dist)
    const destination = packager.getElectronDestinationDir(out)
    log.info({source, destination}, "copying Electron")
    await emptyDir(out)
    await copyDir(source, destination, {
      isUseHardLink: DO_NOT_USE_HARD_LINKS,
    })
  }
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:43,代码来源:dirPackager.ts


示例10: assertPack

export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions?: AssertPackOptions): Promise<void> {
  const tempDirCreated = checkOptions == null ? null : checkOptions.tempDirCreated
  const useTempDir = tempDirCreated != null || packagerOptions.devMetadata != null

  let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName)
  // const isDoNotUseTempDir = platform === "darwin"
  const customTmpDir = process.env.TEST_APP_TMP_DIR
  if (useTempDir) {
    // non-osx test uses the same dir as osx test, but we cannot share node_modules (because tests executed in parallel)
    const dir = customTmpDir == null ? path.join(tmpdir(), `${tmpDirPrefix}${fixtureName}-${tmpDirCounter++}}`) : path.resolve(customTmpDir)
    if (customTmpDir != null) {
      console.log("Custom temp dir used: %s", customTmpDir)
    }
    await emptyDir(dir)
    await copy(projectDir, dir, {
      filter: it => {
        const basename = path.basename(it)
        return basename !== outDirName && basename !== "node_modules" && basename[0] !== "."
      }
    })
    projectDir = dir
  }

  try {
    if (tempDirCreated != null) {
      await tempDirCreated(projectDir)
    }

    await packAndCheck(projectDir, Object.assign({
      projectDir: projectDir,
      cscLink: CSC_LINK,
      cscKeyPassword: CSC_KEY_PASSWORD,
      cscInstallerLink: CSC_INSTALLER_LINK,
      cscInstallerKeyPassword: CSC_INSTALLER_KEY_PASSWORD,
      dist: true,
    }, packagerOptions), checkOptions)

    if (checkOptions != null && checkOptions.packed != null) {
      await checkOptions.packed(projectDir)
    }
  }
  finally {
    if (useTempDir && customTmpDir == null) {
      try {
        await remove(projectDir)
      }
      catch (e) {
        console.warn("Cannot delete temporary directory " + projectDir + ": " + (e.stack || e))
      }
    }
  }
}
开发者ID:GabeIsman,项目名称:electron-builder,代码行数:52,代码来源:packTester.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra-p.ensureDir函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra-p.deleteFile函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap