chore: pretty mirror-sync log

This commit is contained in:
pengzhanbo 2025-05-27 17:31:40 +08:00
parent 470513d07b
commit d52856f0fc

View File

@ -3,6 +3,7 @@ import { request } from 'node:https'
import path from 'node:path' import path from 'node:path'
import process from 'node:process' import process from 'node:process'
import { URL } from 'node:url' import { URL } from 'node:url'
import pc from 'picocolors'
const pluginsDir = path.resolve(process.cwd(), 'plugins') const pluginsDir = path.resolve(process.cwd(), 'plugins')
const plugins = fs.readdirSync(pluginsDir) const plugins = fs.readdirSync(pluginsDir)
@ -23,13 +24,12 @@ async function npmMirrorSync() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const req = request(url, { const req = request(url, {
method: 'PUT', method: 'PUT',
headers: { headers: { 'Content-Length': 0 },
'Content-Length': 0,
},
}) })
req.write('') req.write('')
req.on('close', () => { req.on('close', () => {
console.log(`${pc.green('✓')} sync ${pc.cyan(pkg)}`)
resolve() resolve()
}) })
@ -44,7 +44,7 @@ async function npmMirrorSync() {
try { try {
await npmMirrorSync() await npmMirrorSync()
console.log('npm mirror sync success !') console.log(pc.green('npm mirror sync success !'))
} }
catch (error) { catch (error) {
console.error(error) console.error(error)