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


TypeScript fs.walk函數代碼示例

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


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

示例1: verifySmartUnpack

async function verifySmartUnpack(resourceDir: string) {
  expect(await readAsarJson(path.join(resourceDir, "app.asar"), "node_modules/debug/package.json")).toMatchObject({
    name: "debug"
  })

  expect((await walk(resourceDir, file => !path.basename(file).startsWith("."))).map(it => it.substring(resourceDir.length + 1))).toMatchSnapshot()
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:7,代碼來源:BuildTest.ts

示例2: encodedZip

async function encodedZip(archive: any, dir: string, prefix: string, vendorPath: string, packager: WinPackager) {
  await walk(dir, null, {
    isIncludeDir: true,
    consume: async (file, stats) => {
      if (stats.isDirectory()) {
        return
      }

      // GBK file name encoding (or Non-English file name) caused a problem
      const relativeSafeFilePath = encodeURI(file.substring(dir.length + 1).replace(/\\/g, "/")).replace(/%5B/g, "[").replace(/%5D/g, "]")
      archive._append(file, {
        name: relativeSafeFilePath,
        prefix,
        stats,
      })

      // createExecutableStubForExe
      // https://github.com/Squirrel/Squirrel.Windows/pull/1051 Only generate execution stubs for the top-level executables
      if (file.endsWith(".exe") && !file.includes("squirrel.exe") && !relativeSafeFilePath.includes("/")) {
        const tempFile = await packager.getTempFile("stub.exe")
        await copyFile(path.join(vendorPath, "StubExecutable.exe"), tempFile)
        await execWine(path.join(vendorPath, "WriteZipToSetup.exe"), ["--copy-stub-resources", file, tempFile])
        await packager.sign(tempFile)

        archive._append(tempFile, {
          name: relativeSafeFilePath.substring(0, relativeSafeFilePath.length - 4) + "_ExecutionStub.exe",
          prefix,
          stats: await stat(tempFile),
        })
      }
    }
  })
  archive.finalize()
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:34,代碼來源:squirrelPack.ts

示例3: computeFileSets

export async function computeFileSets(matchers: Array<FileMatcher>, transformer: FileTransformer, packager: Packager, isElectronCompile: boolean): Promise<Array<FileSet>> {
  const fileSets: Array<FileSet> = []
  for (const matcher of matchers) {
    const fileWalker = new AppFileWalker(matcher, packager)

    const fromStat = await statOrNull(fileWalker.matcher.from)
    if (fromStat == null) {
      debug(`Directory ${fileWalker.matcher.from} doesn't exists, skip file copying`)
      continue
    }

    const files = await walk(fileWalker.matcher.from, fileWalker.filter, fileWalker)
    const metadata = fileWalker.metadata

    const transformedFiles = await BluebirdPromise.map(files, it => {
      const fileStat = metadata.get(it)
      return fileStat != null && fileStat.isFile() ? transformer(it) : null
    }, CONCURRENCY)

    fileSets.push({src: fileWalker.matcher.from, files, metadata: fileWalker.metadata, transformedFiles, destination: fileWalker.matcher.to})
  }

  const mainFileSet = fileSets[0]
  if (isElectronCompile) {
    // cache should be first in the asar
    fileSets.unshift(await compileUsingElectronCompile(mainFileSet, packager))
  }
  return fileSets
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:29,代碼來源:AppFileCopierHelper.ts

示例4: expect

  packed: async context => {
    const resourceDir = context.getResources(Platform.LINUX)
    expect(await readAsarJson(path.join(resourceDir, "app.asar"), "node_modules/debug/package.json")).toMatchObject({
      name: "debug"
    })

    expect((await walk(resourceDir, file => !path.basename(file).startsWith("."))).map(it => it.substring(resourceDir.length + 1))).toMatchSnapshot()
  }
開發者ID:djpereira,項目名稱:electron-builder,代碼行數:8,代碼來源:BuildTest.ts

示例5: computeBlockMap

export async function computeBlockMap(appOutDir: string): Promise<string> {
  const files = new Map<string, Stats>()
  await walk(appOutDir, null, {
    consume: (file, fileStat) => {
      if (fileStat.isFile()) {
        files.set(file, fileStat)
      }
    }
  })

  const info: Array<any> = []
  for (const [file, stat] of files.entries()) {
    const blocks = await computeBlocks(file, stat)
    info.push({name: file.substring(appOutDir.length + 1).replace(/\\/g, "/"), blocks})
  }
  return safeDump(info)
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:17,代碼來源:blockMap.ts

示例6: compileUsingElectronCompile

async function compileUsingElectronCompile(mainFileSet: FileSet, packager: Packager): Promise<FileSet> {
  log("Compiling using electron-compile")

  const electronCompileCache = await packager.tempDirManager.getTempFile("electron-compile-cache")
  const cacheDir = path.join(electronCompileCache, ".cache")
  // clear and create cache dir
  await ensureDir(cacheDir)
  const compilerHost = await createElectronCompilerHost(mainFileSet.src, cacheDir)
  const nextSlashIndex = mainFileSet.src.length + 1
  // pre-compute electron-compile to cache dir - we need to process only subdirectories, not direct files of app dir
  await BluebirdPromise.map(mainFileSet.files, file => {
    if (file.includes(NODE_MODULES_PATTERN) || file.includes(BOWER_COMPONENTS_PATTERN)
      || !file.includes(path.sep, nextSlashIndex) // ignore not root files
      || !mainFileSet.metadata.get(file)!.isFile()) {
      return null
    }
    return compilerHost.compile(file)
      .then((it: any) => null)
  }, CONCURRENCY)

  await compilerHost.saveConfiguration()

  const metadata = new Map<string, Stats>()
  const cacheFiles = await walk(cacheDir, (file, stat) => !file.startsWith("."), {
    consume: (file, fileStat) => {
      if (fileStat.isFile()) {
        metadata.set(file, fileStat)
      }
      return null
    }
  })

  // add shim
  const shimPath = `${mainFileSet.src}/${ELECTRON_COMPILE_SHIM_FILENAME}`
  cacheFiles.push(shimPath)
  metadata.set(shimPath, {isFile: () => true, isDirectory: () => false} as any)

  const transformedFiles = new Array(cacheFiles.length)
  transformedFiles[cacheFiles.length - 1] = `
'use strict';
require('electron-compile').init(__dirname, require('path').resolve(__dirname, '${packager.metadata.main || "index"}'), true);
`
  // cache files should be first (better IO)
  return {src: electronCompileCache, files: cacheFiles, transformedFiles, metadata, destination: mainFileSet.destination}
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:45,代碼來源:AppFileCopierHelper.ts

示例7: listFiles

 function listFiles() {
   return walk(driveC, null, {consume: walkFilter})
 }
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:3,代碼來源:winHelper.ts

示例8: expect

 packed: async context => {
   const dir = path.join(context.projectDir, "dist/s3")
   expect((await walk(dir, file => !path.basename(file).startsWith("."))).map(it => it.substring(dir.length + 1))).toMatchSnapshot()
 }
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:4,代碼來源:PublishManagerTest.ts

示例9: listFiles

 function listFiles() {
   return walk(driveC, null, walkFilter)
 }
開發者ID:mbrainiac,項目名稱:electron-builder,代碼行數:3,代碼來源:nsisTest.ts


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