當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra-p.writeFile函數代碼示例

本文整理匯總了TypeScript中fs-extra-p.writeFile函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript writeFile函數的具體用法?TypeScript writeFile怎麽用?TypeScript writeFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了writeFile函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: writeFile

 projectDirCreated: projectDir => {
   return Promise.all([
     // writeFile(path.join(projectDir, "build", "license_en.txt"), "Hi"),
     writeFile(path.join(projectDir, "build", "license_de.txt"), "Hallo"),
     writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет"),
   ])
 },
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:7,代碼來源:dmgTest.ts

示例2: writeFile

 projectDirCreated: projectDir => {
   return BluebirdPromise.all([
     writeFile(path.join(projectDir, "build", "license_en.txt"), "Hi"),
     writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет"),
     writeFile(path.join(projectDir, "build", "license_ko.txt"), "Привет"),
     writeFile(path.join(projectDir, "build", "license_fi.txt"), "Привет"),
   ])
 },
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:8,代碼來源:oneClickInstallerTest.ts

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

示例4: copy

  async copy(src: string, dest: string, stat: Stats | undefined) {
    if (this.transformer != null && stat != null && stat.isFile()) {
      let data = this.transformer(src)
      if (data != null) {
        if (typeof (data as any).then === "function") {
          data = await data
        }

        if (data != null) {
          await writeFile(dest, data)
          return
        }
      }
    }
    const isUseHardLink = (!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest)
    await copyOrLinkFile(src, dest, stat, isUseHardLink, isUseHardLink ? () => {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (this.isUseHardLink) {
        this.isUseHardLink = false
        return true
      }
      else {
        return false
      }
    } : null)
  }
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:26,代碼來源:fs.ts

示例5: copy

  async copy(src: string, dest: string, stat: Stats | undefined) {
    try {
      if (this.transformer != null && stat != null && stat.isFile()) {
        let data = this.transformer(src)
        if (data != null) {
          if (typeof (data as any).then === "function") {
            data = await data
          }

          if (data != null) {
            await writeFile(dest, data)
            return
          }
        }
      }
      await copyOrLinkFile(src, dest, stat, (!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest))
    }
    catch (e) {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (e.code === "EXDEV") {
        // ...but here we want to avoid excess debug log message
        if (this.isUseHardLink) {
          debug(`Cannot copy using hard link: ${e}`)
          this.isUseHardLink = false
        }

        await copyOrLinkFile(src, dest, stat, false)
      }
      else {
        throw e
      }
    }
  }
開發者ID:jwheare,項目名稱:electron-builder,代碼行數:33,代碼來源:fs.ts

示例6: setPackageVersions

async function setPackageVersions(packageData: Array<any>) {
  const versions = await getLatestVersions(packageData)
  let publishScript = `#!/usr/bin/env bash
set -e
  
ln -f README.md packages/electron-builder/README.md
`

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const packageName = packageMetadata.name
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion == null || packageMetadata.version === latestVersion || semver.lt(latestVersion, packageMetadata.version)) {
      continue
    }

    packageMetadata.version = latestVersion
    console.log(`Set ${packageName} version to ${latestVersion}`)
    await writeJson(path.join(packageDir, packageName, "package.json"), packageMetadata, {spaces: 2})
  }

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion != null && semver.gt(packageMetadata.version, latestVersion)) {
      publishScript += `npm publish packages/${packageMetadata.name}\n`
    }
  }

  await writeFile(path.join(rootDir, "__publish.sh"), publishScript)
}
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:33,代碼來源:setVersions.ts

示例7: createFiles

async function createFiles(appDir: string) {
  await BluebirdPromise.all([
    outputFile(path.join(appDir, "assets", "file"), "data"),
    outputFile(path.join(appDir, "b2", "file"), "data"),
    outputFile(path.join(appDir, "do-not-unpack-dir", "file.json"), "{}")
      .then(() => writeFile(path.join(appDir, "do-not-unpack-dir", "must-be-not-unpacked"), "{}"))
  ])

  const dir = path.join(appDir, "do-not-unpack-dir", "dir-2", "dir-3", "dir-3")
  await mkdirs(dir)
  await writeFile(path.join(dir, "file-in-asar"), "{}")
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:12,代碼來源:globTest.ts

示例8: safeLoad

      packed: async context => {
        const outDir = context.outDir
        outDirs.push(outDir)
        const targetOutDir = path.join(outDir, "nsis-web")
        const updateInfoFile = path.join(targetOutDir, "latest.yml")

        const updateInfo: UpdateInfo = safeLoad(await readFile(updateInfoFile, "utf-8"))
        const fd = await open(path.join(targetOutDir, `TestApp-${version}-x64.nsis.7z`), "r")
        try {
          const packageInfo = updateInfo.packages!!.x64
          const buffer = Buffer.allocUnsafe(packageInfo.blockMapSize!!)
          await read(fd, buffer, 0, buffer.length, packageInfo.size - buffer.length)
          const inflateRaw: any = BluebirdPromise.promisify(require("zlib").inflateRaw)
          const blockMapData = (await inflateRaw(buffer)).toString()
          await writeFile(path.join(outDir, "win-unpacked", BLOCK_MAP_FILE_NAME), blockMapData)
        }
        finally {
          await close(fd)
        }
      }
開發者ID:jwheare,項目名稱:electron-builder,代碼行數:20,代碼來源:differentialUpdateTest.ts

示例9: addLicenseToDmg

export async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath: string) {
  // http://www.owsiak.org/?p=700
  const licenseFiles = await getLicenseFiles(packager)
  if (licenseFiles.length === 0) {
    return
  }

  if (debug.enabled) {
    debug(`License files: ${licenseFiles.join(" ")}`)
  }

  const tempFile = await packager.getTempFile(".r")
  let data = await readFile(path.join(__dirname, "..", "..", "templates", "dmg", "license.txt"), "utf8")
  let counter = 5000
  for (const item of licenseFiles) {
    const kind = item.file.toLowerCase().endsWith(".rtf") ? "RTF" : "TEXT"
    data += `data '${kind}' (${counter}, "${item.langName} SLA") {\n`

    const hex = (await readFile(item.file)).toString("hex").toUpperCase()
    for (let i = 0; i < hex.length; i += 32) {
      data += '$"' + hex.substring(i, Math.min(i + 32, hex.length)) + '"\n'
    }

    data += "};\n\n"
    // noinspection SpellCheckingInspection
    data += `data 'styl' (${counter}, "${item.langName} SLA") {
  $"0003 0000 0000 000C 0009 0014 0000 0000"
  $"0000 0000 0000 0000 0027 000C 0009 0014"
  $"0100 0000 0000 0000 0000 0000 002A 000C"
  $"0009 0014 0000 0000 0000 0000 0000"
};`

    counter++
  }

  await writeFile(tempFile, data)
  await exec("hdiutil", ["unflatten", dmgPath])
  await exec("Rez", ["-a", tempFile, "-o", dmgPath])
  await exec("hdiutil", ["flatten", dmgPath])
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:40,代碼來源:dmgLicense.ts

示例10: copy

  async copy(src: string, dest: string, stat: Stats | undefined) {
    let afterCopyTransformer: AfterCopyFileTransformer | null = null
    if (this.transformer != null && stat != null && stat.isFile()) {
      let data = this.transformer(src)
      if (data != null) {
        if (typeof data === "object" && "then" in data) {
          data = await data
        }

        if (data != null) {
          if (data instanceof CopyFileTransformer) {
            afterCopyTransformer = data.afterCopyTransformer
          }
          else {
            await writeFile(dest, data)
            return
          }
        }
      }
    }

    const isUseHardLink = afterCopyTransformer == null && ((!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest))
    await copyOrLinkFile(src, dest, stat, isUseHardLink, isUseHardLink ? () => {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (this.isUseHardLink) {
        this.isUseHardLink = false
        return true
      }
      else {
        return false
      }
    } : null)

    if (afterCopyTransformer != null) {
      await afterCopyTransformer(dest)
    }
  }
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:37,代碼來源:fs.ts


注:本文中的fs-extra-p.writeFile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。