refactor: esm
This commit is contained in:
parent
a417c26d7f
commit
27c088987c
|
@ -10,5 +10,6 @@
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14.15.0"
|
"node": ">= 14.15.0"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|
19
src/build.js
19
src/build.js
|
@ -2,14 +2,15 @@
|
||||||
|
|
||||||
// for deployment outside of GitLab CI, e.g. Cloudflare Pages and Netlify
|
// for deployment outside of GitLab CI, e.g. Cloudflare Pages and Netlify
|
||||||
|
|
||||||
const { stream: gotStream } = require('got')
|
import got from 'got'
|
||||||
const got = require('got')
|
import unzip from 'extract-zip'
|
||||||
const unzip = require('extract-zip')
|
import { dirname, join } from 'node:path'
|
||||||
const { join } = require('path')
|
import { mkdir } from 'node:fs/promises'
|
||||||
const { mkdir } = require('fs/promises')
|
import { createWriteStream } from 'node:fs'
|
||||||
const { createWriteStream } = require('fs')
|
import { pipeline } from 'node:stream/promises'
|
||||||
const { pipeline } = require('stream/promises')
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||||
const rootPath = join(__dirname, '..')
|
const rootPath = join(__dirname, '..')
|
||||||
const tmpPath = join(rootPath, 'tmp')
|
const tmpPath = join(rootPath, 'tmp')
|
||||||
const publicPath = join(rootPath, 'public')
|
const publicPath = join(rootPath, 'public')
|
||||||
|
@ -35,7 +36,7 @@ const f = async () => {
|
||||||
console.log(`Downloading artifacts.zip from "${artifactsUrl}"`)
|
console.log(`Downloading artifacts.zip from "${artifactsUrl}"`)
|
||||||
try {
|
try {
|
||||||
await pipeline(
|
await pipeline(
|
||||||
gotStream(artifactsUrl),
|
got.stream(artifactsUrl),
|
||||||
createWriteStream(zipPath)
|
createWriteStream(zipPath)
|
||||||
)
|
)
|
||||||
await pipelineStatus(pipelineUrl)
|
await pipelineStatus(pipelineUrl)
|
||||||
|
@ -50,7 +51,7 @@ const f = async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await pipeline(
|
await pipeline(
|
||||||
gotStream(ghMirror),
|
got.stream(ghMirror),
|
||||||
createWriteStream(zipPath)
|
createWriteStream(zipPath)
|
||||||
)
|
)
|
||||||
} catch ({ message }) {
|
} catch ({ message }) {
|
||||||
|
|
Loading…
Reference in New Issue