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


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

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


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

示例1: deleteOldElectronVersion

async function deleteOldElectronVersion(): Promise<any> {
  if (!process.env.CI) {
    return
  }

  const cacheDir = path.join(require("os").homedir(), ".electron")
  try {
    const deletePromises: Array<Promise<any>> = []
    for (let file of (await readdir(cacheDir))) {
      if (file.endsWith(".zip") && !file.includes(electronVersion)) {
        console.log("Remove old electron " + file)
        deletePromises.push(unlink(path.join(cacheDir, file)))
      }
    }
    return BluebirdPromise.all(deletePromises)
  }
  catch (e) {
    if (e.code === "ENOENT") {
      return []
    }
    else {
      throw e
    }
  }
}
開發者ID:MathijsvVelde,項目名稱:electron-builder,代碼行數:25,代碼來源:runTests.ts

示例2: main

async function main(): Promise<void> {
  const packages = (await readdir(packageDir)).filter(it => !it.includes(".")).sort()
  const devPackageData = await readJson(path.join(rootDir, "package.json"))
  if ((await BluebirdPromise.map(packages, it => check(path.join(packageDir, it), devPackageData))).includes(false)) {
    process.exitCode = 1
  }
}
開發者ID:jwheare,項目名稱:electron-builder,代碼行數:7,代碼來源:checkDeps.ts

示例3: readScopedDir

async function readScopedDir(dir: string) {
  let files: Array<string>
  try {
    files = (await readdir(dir)).filter(it => !it.startsWith("."))
  }
  catch (e) {
    // error indicates that nothing is installed here
    return []
  }

  files.sort()

  const scopes = files.filter(it => it.startsWith("@"))
  if (scopes.length === 0) {
    return files
  }

  const result = files.filter(it => !it.startsWith("@"))
  const scopeFileList = await BluebirdPromise.map(scopes, it => readdir(path.join(dir, it)))
  for (let i = 0; i < scopes.length; i++) {
    for (const file of scopeFileList[i]) {
      if (!file.startsWith(".")) {
        result.push(`${scopes[i]}/${file}`)
      }
    }
  }

  result.sort()
  return result
}
開發者ID:djpereira,項目名稱:electron-builder,代碼行數:30,代碼來源:readInstalled.ts

示例4: deleteOldElectronVersion

async function deleteOldElectronVersion(): Promise<any> {
  if (!isCi) {
    return
  }

  const cacheDir = require("env-paths")("electron", {suffix: ""}).cache
  try {
    const deletePromises: Array<Promise<any>> = []
    for (const file of (await readdir(cacheDir))) {
      if (file.endsWith(".zip") && !file.includes(ELECTRON_VERSION)) {
        console.log(`Remove old electron ${file}`)
        deletePromises.push(unlink(path.join(cacheDir, file)))
      }
    }
    return await BluebirdPromise.all(deletePromises)
  }
  catch (e) {
    if (e.code === "ENOENT") {
      return []
    }
    else {
      throw e
    }
  }
}
開發者ID:djpereira,項目名稱:electron-builder,代碼行數:25,代碼來源:runTests.ts

示例5: deleteOldElectronVersion

function deleteOldElectronVersion(): Promise<any> {
  if (process.env.CI) {
    const cacheDir = path.join(require("os").homedir(), ".electron")
    return fs.readdir(cacheDir)
      .catch(error => {
        if (error.code === "ENOENT") {
          return []
        }
        else {
          throw error
        }
      })
      .then(it => {
        const deletePromises: Array<Promise<any>> = []
        for (let file of it) {
          if (file.endsWith(".zip") && !file.includes(electronVersion)) {
            console.log("Remove old electron " + file)
            deletePromises.push(fs.unlink(path.join(cacheDir, file)))
          }
        }
        return BluebirdPromise.all(deletePromises)
      })
  }
  else {
    return BluebirdPromise.resolve()
  }
}
開發者ID:waifei,項目名稱:electron-builder,代碼行數:27,代碼來源:runTests.ts

示例6: readScopedDir

async function readScopedDir(dir: string): Promise<Array<string> | null> {
  let files: Array<string>
  try {
    files = (await readdir(dir)).filter(it => !it.startsWith(".") && !knownAlwaysIgnoredDevDeps.has(it))
  }
  catch (e) {
    // error indicates that nothing is installed here
    return null
  }

  files.sort()

  const scopes = files.filter(it => it.startsWith("@") && it !== "@types")
  if (scopes.length === 0) {
    return files
  }

  const result = files.filter(it => !it.startsWith("@"))
  const scopeFileList = await BluebirdPromise.map(scopes, it => readdir(path.join(dir, it)))
  for (let i = 0; i < scopes.length; i++) {
    const list = scopeFileList[i]
    list.sort()
    for (const file of list) {
      if (!file.startsWith(".")) {
        result.push(`${scopes[i]}/${file}`)
      }
    }
  }

  return result
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:31,代碼來源:packageDependencies.ts

示例7: readProjectMetadata

async function readProjectMetadata(packageDir: string) {
  const packageDirs = BluebirdPromise.filter((await readdir(packageDir)).filter(it => !it.includes(".")).sort(), it => {
    return stat(path.join(packageDir, it, "package.json"))
      .then(it => it.isFile())
      .catch(() => false)
  })
  return await BluebirdPromise.map(packageDirs, it => readJson(path.join(packageDir, it, "package.json")), {concurrency: 8})
}
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:8,代碼來源:setVersions.ts

示例8: computeData

export async function computeData(resourcesPath: string, options?: AsarIntegrityOptions | null): Promise<AsarIntegrity> {
  // sort to produce constant result
  const names = (await readdir(resourcesPath)).filter(it => it.endsWith(".asar")).sort()
  const checksums = await BluebirdPromise.map(names, it => hashFile(path.join(resourcesPath, it)))

  const result: { [key: string]: string; } = {}
  for (let i = 0; i < names.length; i++) {
    result[names[i]] = checksums[i]
  }
  return {checksums: result, ...options}
}
開發者ID:jwheare,項目名稱:electron-builder,代碼行數:11,代碼來源:main.ts

示例9: main

async function main(): Promise<void> {
  const packages = (await readdir(packageDir)).filter(it => !it.includes(".")).sort()

  const packageData = await BluebirdPromise.map(packages, it => readJson(path.join(packageDir, it, "package.json")))
  const args = process.argv.slice(2)
  if (args.length > 0 && args[0] === "p") {
    await setPackageVersions(packages, packageData)
  }
  else {
    await setDepVersions(packages, packageData)
  }
}
開發者ID:mbrainiac,項目名稱:electron-builder,代碼行數:12,代碼來源:setVersions.ts

示例10: main

async function main(): Promise<void> {
  const packages = (await readdir(packageDir)).filter(it => !it.includes(".")).sort()
  for (const name of packages) {
    if (name.includes("electron-forge-maker-") || name.includes("electron-installer-")) {
      continue
    }

    workers(path.join(packageDir, name), (error: Error, hasError: boolean) => {
      if (hasError) {
        process.exitCode = 1
      }
    })
  }
  workerFarm.end(workers)
}
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:15,代碼來源:lint.ts


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