Skip to content

Commit

Permalink
fix: ESM syntaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 2, 2024
1 parent eb8f1a8 commit 64dacfb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 45 deletions.
2 changes: 1 addition & 1 deletion bin/sponsorkit.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
await import('../dist/cli.mjs')
import '../dist/cli.mjs'
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"type": "module",
"private": true,
"scripts": {
"build": "sponsorkit",
"build:dev": "esno ../src/cli.ts"
},
"devDependencies": {
"sponsorkit": "latest"
"sponsorkit": "workspace:*"
}
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"dependencies": {
"consola": "^3.2.3",
"d3-hierarchy": "^3.1.2",
"datauri": "^4.1.0",
"dotenv": "^16.4.5",
"node-html-parser": "^6.1.13",
"ofetch": "^1.3.4",
Expand Down
35 changes: 0 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { scriptName } from 'yargs'
import process from 'node:process'
import yargs from 'yargs'
import { version } from '../package.json'
import { run } from './run'
import type { SponsorkitConfig } from './types'

const cli = scriptName('sponsors-svg')
const cli = yargs(process.argv.slice(2))
.scriptName('sponsors-svg')
.usage('$0 [args]')
.version(version)
.strict()
Expand Down
7 changes: 2 additions & 5 deletions src/processing/image.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Buffer } from 'node:buffer'
import { $fetch } from 'ofetch'
import DatauriParser from 'datauri/parser'
import sharp from 'sharp'
import { consola } from 'consola'
import pLimit from 'p-limit'
import { version } from '../../package.json'
import type { SponsorkitConfig, Sponsorship } from '../types'

Expand All @@ -22,6 +20,7 @@ export async function resolveAvatars(

const fallbackDataUri = fallbackAvatar && pngToDataUri(await round(fallbackAvatar, 0.5, 100))

const pLimit = await import('p-limit').then(r => r.default)
const limit = pLimit(15)

return Promise.all(ships.map(ship => limit(async () => {
Expand Down Expand Up @@ -104,8 +103,6 @@ export function svgToPng(svg: string) {
.toBuffer()
}

const parser = new DatauriParser()

export function pngToDataUri(png: Buffer) {
return parser.format('.png', png).content
return `data:image/png;base64,${png.toString('base64')}`
}

0 comments on commit 64dacfb

Please sign in to comment.