本文整理汇总了TypeScript中builder-util/out/nodeHttpExecutor.httpExecutor类的典型用法代码示例。如果您正苦于以下问题:TypeScript httpExecutor类的具体用法?TypeScript httpExecutor怎么用?TypeScript httpExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了httpExecutor类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: computeElectronVersion
export async function computeElectronVersion(projectDir: string, projectMetadata: MetadataValue): Promise<string> {
const result = await getElectronVersionFromInstalled(projectDir)
if (result != null) {
return result
}
const electronPrebuiltDep = findFromElectronPrebuilt(await projectMetadata!!.value)
if (electronPrebuiltDep == null || electronPrebuiltDep === "latest") {
try {
const releaseInfo = JSON.parse((await httpExecutor.request({
hostname: "github.com",
path: "/electron/electron/releases/latest",
headers: {
Accept: "application/json",
},
}))!!)
return (releaseInfo.tag_name.startsWith("v")) ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name
}
catch (e) {
warn(e)
}
throw new Error(`Cannot find electron dependency to get electron version in the '${path.join(projectDir, "package.json")}'`)
}
const firstChar = electronPrebuiltDep[0]
return firstChar === "^" || firstChar === "~" ? electronPrebuiltDep.substring(1) : electronPrebuiltDep
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:28,代码来源:electronVersion.ts
示例2: downloadCertificate
export async function downloadCertificate(urlOrBase64: string, tmpDir: TmpDir, currentDir: string): Promise<string> {
urlOrBase64 = urlOrBase64.trim()
let file: string | null = null
if ((urlOrBase64.length > 3 && urlOrBase64[1] === ":") || urlOrBase64.startsWith("/") || urlOrBase64.startsWith(".")) {
file = urlOrBase64
}
else if (urlOrBase64.startsWith("file://")) {
file = urlOrBase64.substring("file://".length)
}
else if (urlOrBase64.startsWith("~/")) {
file = path.join(homedir(), urlOrBase64.substring("~/".length))
}
else {
const isUrl = urlOrBase64.startsWith("https://")
if (isUrl || urlOrBase64.length > 2048 || urlOrBase64.endsWith("=")) {
const tempFile = await tmpDir.getTempFile({suffix: ".p12"})
if (isUrl) {
await httpExecutor.download(urlOrBase64, tempFile)
}
else {
await outputFile(tempFile, Buffer.from(urlOrBase64, "base64"))
}
return tempFile
}
else {
file = urlOrBase64
}
}
file = path.resolve(currentDir, file)
const stat = await statOrNull(file)
if (stat == null) {
throw new Error(`${file} doesn't exist`)
}
else if (!stat.isFile()) {
throw new Error(`${file} not a file`)
}
else {
return file
}
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:42,代码来源:codeSign.ts
示例3: async
test.ifAll.ifDevOrLinuxCi("download to nonexistent dir", async () => {
const tempFile = await tmpDir.getTempFile()
await httpExecutor.download("https://drive.google.com/uc?export=download&id=0Bz3JwZ-jqfRONTkzTGlsMkM2TlE", tempFile)
await assertThat(tempFile).isFile()
})
开发者ID:jwheare,项目名称:electron-builder,代码行数:5,代码来源:httpRequestTest.ts
注:本文中的builder-util/out/nodeHttpExecutor.httpExecutor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论