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


TypeScript asar-electron-builder.extractFile函數代碼示例

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


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

示例1: assertThat

 packed: async context => {
   await assertThat(path.join(context.getContent(Platform.LINUX), "new-name")).isFile()
   assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "package.json").toString())).hasProperties({
     foo: {
       bar: 12,
       existingProp: 22,
     }
   })
 }
開發者ID:heinzbeinz,項目名稱:electron-builder,代碼行數:9,代碼來源:extraMetadataTest.ts

示例2: doTest

async function doTest(outDir: string, perUser: boolean) {
  if (process.env.DO_WINE !== "true") {
    return BluebirdPromise.resolve()
  }

  const wine = new WineManager()
  await wine.prepare()
  const driveC = path.join(wine.wineDir, "drive_c")
  const driveCWindows = path.join(wine.wineDir, "drive_c", "windows")
  const perUserTempDir = path.join(wine.userDir, "Temp")
  const walkFilter = (it: string) => {
    return it !== driveCWindows && it !== perUserTempDir
  }

  function listFiles() {
    return walk(driveC, null, walkFilter)
  }

  let fsBefore = await listFiles()

  await wine.exec(path.join(outDir, "TestApp Setup 1.1.0.exe"), "/S")

  const instDir = perUser ? path.join(wine.userDir, "Local Settings", "Application Data", "Programs") : path.join(driveC, "Program Files")
  const appAsar = path.join(instDir, "TestApp", "1.1.0", "resources", "app.asar")
  assertThat(JSON.parse(extractFile(appAsar, "package.json").toString())).hasProperties({
    name: "TestApp"
  })

  let fsAfter = await listFiles()

  let fsChanges = diff(fsBefore, fsAfter, driveC)
  assertThat(fsChanges.added).isEqualTo(nsisPerMachineInstall)
  assertThat(fsChanges.deleted).isEqualTo([])

  // run installer again to test uninstall
  const appDataFile = path.join(wine.userDir, "Application Data", "TestApp", "doNotDeleteMe")
  await outputFile(appDataFile, "app data must be not removed")
  fsBefore = await listFiles()
  await wine.exec(path.join(outDir, "TestApp Setup 1.1.0.exe"), "/S")
  fsAfter = await listFiles()

  fsChanges = diff(fsBefore, fsAfter, driveC)
  assertThat(fsChanges.added).isEqualTo([])
  assertThat(fsChanges.deleted).isEqualTo([])

  await assertThat(appDataFile).isFile()

  await wine.exec(path.join(outDir, "TestApp Setup 1.1.0.exe"), "/S", "--delete-app-data")
  await assertThat(appDataFile).doesNotExist()
}
開發者ID:Icenium,項目名稱:electron-builder,代碼行數:50,代碼來源:nsisTest.ts

示例3: loadConfig

export async function loadConfig(projectDir: string): Promise<Config | null> {
  try {
    const configPath = path.join(projectDir, "electron-builder.yml")
    const result = safeLoad(await readFile(configPath, "utf8"))
    log(`Using ${path.relative(projectDir, configPath)} configuration file`)
    return result
  }
  catch (e) {
    if (e.code !== "ENOENT") {
      throw e
    }
  }

  try {
    return getConfigFromPackageData(await readPackageJson(path.join(projectDir, "package.json")))
  }
  catch (e) {
    if (e.code !== "ENOENT") {
      throw e
    }

    try {
      const file = extractFile(path.join(projectDir, "app.asar"), "package.json")
      if (file != null) {
        return getConfigFromPackageData(JSON.parse(file.toString()))
      }
    }
    catch (e) {
      if (e.code !== "ENOENT") {
        throw e
      }
    }

    throw new Error(`Cannot find package.json in the ${projectDir}`)
  }
}
開發者ID:mbrainiac,項目名稱:electron-builder,代碼行數:36,代碼來源:readPackageJson.ts

示例4: assertThat

 packed: async context => {
   await assertThat(path.join(context.getContent(Platform.LINUX), "new-name")).isFile()
   expect(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "package.json").toString())).toMatchSnapshot()
 }
開發者ID:mbrainiac,項目名稱:electron-builder,代碼行數:4,代碼來源:extraMetadataTest.ts

示例5: doTest

async function doTest(outDir: string, perUser: boolean, productFilename = "TestApp Setup", name = "TestApp", menuCategory: string | null = null) {
  if (process.env.DO_WINE !== "true") {
    return BluebirdPromise.resolve()
  }

  const wine = new WineManager()
  await wine.prepare()
  const driveC = path.join(wine.wineDir, "drive_c")
  const driveCWindows = path.join(wine.wineDir, "drive_c", "windows")
  const perUserTempDir = path.join(wine.userDir, "Temp")
  const walkFilter = (it: string) => {
    return it !== driveCWindows && it !== perUserTempDir
  }

  function listFiles() {
    return walk(driveC, null, walkFilter)
  }

  let fsBefore = await listFiles()

  await wine.exec(path.join(outDir, `${productFilename} Setup 1.1.0.exe`), "/S")

  let instDir = perUser ? path.join(wine.userDir, "Local Settings", "Application Data", "Programs") : path.join(driveC, "Program Files")
  if (menuCategory != null) {
    instDir = path.join(instDir, menuCategory)
  }

  const appAsar = path.join(instDir, name, "resources", "app.asar")
  expect(JSON.parse(extractFile(appAsar, "package.json").toString())).toMatchObject({
    name: name,
  })

  if (!perUser) {
    let startMenuDir = path.join(driveC, "users", "Public", "Start Menu", "Programs")
    if (menuCategory != null) {
      startMenuDir = path.join(startMenuDir, menuCategory)
    }
    await assertThat(path.join(startMenuDir, `${productFilename}.lnk`)).isFile()
  }

  let fsAfter = await listFiles()

  let fsChanges = diff(fsBefore, fsAfter, driveC)
  expect(fsChanges.added).toMatchSnapshot()
  expect(fsChanges.deleted).toEqual([])

  // run installer again to test uninstall
  const appDataFile = path.join(wine.userDir, "Application Data", name, "doNotDeleteMe")
  await outputFile(appDataFile, "app data must be not removed")
  fsBefore = await listFiles()
  await wine.exec(path.join(outDir, `${productFilename} Setup 1.1.0.exe`), "/S")
  fsAfter = await listFiles()

  fsChanges = diff(fsBefore, fsAfter, driveC)
  expect(fsChanges.added).toEqual([])
  expect(fsChanges.deleted).toEqual([])

  await assertThat(appDataFile).isFile()

  await wine.exec(path.join(outDir, `${productFilename} Setup 1.1.0.exe`), "/S", "--delete-app-data")
  await assertThat(appDataFile).doesNotExist()
}
開發者ID:mbrainiac,項目名稱:electron-builder,代碼行數:62,代碼來源:nsisTest.ts


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