fix: script to fetch

This commit is contained in:
Innei
2022-05-21 17:15:40 +08:00
parent 7d05e7ca63
commit 6125c4f3ab
4 changed files with 9 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
#!env node
const { createWriteStream, writeFileSync } = require('fs')
const { writeFileSync, appendFileSync } = require('fs')
const { join } = require('path')
const { fetch, $ } = require('zx-cjs')
const {
@@ -12,8 +12,8 @@ const endpoint = `https://api.github.com/repos/${repo}/releases/tags/v${version}
const downloadUrl = json.assets.find(
(asset) => asset.name === 'release.zip',
).browser_download_url
const buffer = await fetch(downloadUrl).then((res) => res.buffer())
writeFileSync(join(process.cwd(), 'admin-release.zip'), buffer)
const buffer = await fetch(downloadUrl).then((res) => res.arrayBuffer())
appendFileSync(join(process.cwd(), 'admin-release.zip'), Buffer.from(buffer))
await $`ls -lh`

View File

@@ -16,6 +16,8 @@ function getOsBuildAssetName() {
return `release-${os}-latest.zip`
}
const { appendFileSync } = require('fs')
const PKG = require('../package.json')
async function main() {
const res = await fetch(
@@ -30,9 +32,9 @@ async function main() {
}
const buffer = await fetch('https://cc.shizuri.net/' + downloadUrl).then(
(res) => res.buffer(),
(res) => res.arrayBuffer(),
)
fs.writeFileSync(`release-downloaded.zip`, buffer, { flag: 'w' })
appendFileSync(`release-downloaded.zip`, Buffer.from(buffer))
await $`unzip release-downloaded.zip -d mx-server`
}