Skip to content

Commit

Permalink
chore: Updated dependencies and toolchain.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShogunPanda committed Oct 23, 2023
1 parent 559be23 commit ef79c07
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
version: latest
- name: Install dependencies
run: pnpm install
run: pnpm install --shamefully-hoist
- name: Run Tests
run: pnpm run ci
- name: Upload coverage to Codecov
Expand Down
38 changes: 21 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,39 @@
"types": "./dist/index.d.ts",
"scripts": {
"dev": "swc --delete-dir-on-start -s -w -d dist src",
"prebuild": "rm -rf dist && npm run lint",
"build": "swc -d dist src",
"postbuild": "tsc -p . --emitDeclarationOnly",
"build": "swc --delete-dir-on-start -d dist src",
"postbuild": "concurrently npm:lint npm:typecheck",
"format": "prettier -w src test",
"lint": "eslint src test",
"test": "c8 -c test/config/c8-local.json tap --rcfile=test/config/tap.yml test/*.test.ts",
"test:ci": "c8 -c test/config/c8-ci.json tap --rcfile=test/config/tap.yml --no-color test/*.test.ts",
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src test",
"typecheck": "tsc -p . --emitDeclarationOnly",
"test": "c8 -c test/config/c8-local.json tap test/*.test.ts",
"test:ci": "c8 -c test/config/c8-ci.json tap --no-color test/*.test.ts",
"ci": "npm run build && npm run test:ci",
"prepublishOnly": "npm run ci",
"postpublish": "git push origin && git push origin -f --tags"
},
"dependencies": {
"image-size": "^1.0.2",
"undici": "^5.12.0"
"undici": "^5.26.5"
},
"devDependencies": {
"@cowtech/eslint-config": "^8.8.0",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.3.19",
"@types/node": "^18.11.9",
"@types/tap": "^15.0.7",
"c8": "^7.12.0",
"@cowtech/eslint-config": "^8.10.0",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.94",
"@types/node": "^20.8.7",
"@types/tap": "^15.0.10",
"c8": "^8.0.1",
"chokidar": "^3.5.3",
"prettier": "^2.8.0",
"tap": "^16.3.2",
"concurrently": "^8.2.2",
"prettier": "^3.0.3",
"tap": "^18.5.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
"typescript": "^5.2.2"
},
"engines": {
"node": ">=14.15.0"
"node": ">= 18.18.0"
},
"tap": {
"extends": "./test/config/tap.yml"
}
}
7 changes: 4 additions & 3 deletions src/callback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ImageInfo } from './models.js'
import { type ImageInfo } from './models.js'

export type Callback = (error: Error | null, info?: ImageInfo) => void
type PromiseResolver<T> = (value: T) => void
Expand All @@ -19,10 +19,11 @@ export function ensurePromiseCallback(callback?: Callback): [Callback, Promise<I
return [
(err, info) => {
if (err) {
return promiseReject(err)
promiseReject(err)
return
}

return promiseResolve(info!)
promiseResolve(info!)
},
promise
]
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import EventEmitter from 'node:events'
import { Stream, Writable, WritableOptions } from 'node:stream'
import { Callback, ensurePromiseCallback } from './callback.js'
import { type Stream, type Writable, type WritableOptions } from 'node:stream'
import { type Callback, ensurePromiseCallback } from './callback.js'
import { handleData, handleError, toStream } from './internals.js'
import { defaultOptions, FastImageError, ImageInfo, Options } from './models.js'
import { defaultOptions, FastImageError, type ImageInfo, type Options } from './models.js'
import { FastImageStream } from './stream.js'

export { defaultOptions, FastImageError } from './models.js'
Expand Down
10 changes: 5 additions & 5 deletions src/internals.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import imageSize from 'image-size'
import EventEmitter from 'node:events'
import type EventEmitter from 'node:events'
import { createReadStream } from 'node:fs'
import { IncomingHttpHeaders } from 'node:http'
import { Readable, Stream } from 'node:stream'
import { type IncomingHttpHeaders } from 'node:http'
import { Readable, type Stream } from 'node:stream'
import undici from 'undici'
import { Callback } from './callback.js'
import { FastImageError, ImageInfo } from './models.js'
import { type Callback } from './callback.js'
import { FastImageError, type ImageInfo } from './models.js'

const realUrlHeader = 'x-fastimage-real-url'

Expand Down
4 changes: 2 additions & 2 deletions src/stream.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EventEmitter from 'node:events'
import { Writable, WritableOptions } from 'node:stream'
import { Writable, type WritableOptions } from 'node:stream'
import { handleData } from './internals.js'
import { defaultOptions, FastImageError, Options } from './models.js'
import { defaultOptions, FastImageError, type Options } from './models.js'

export class FastImageStream extends Writable {
buffer: Buffer
Expand Down
4 changes: 2 additions & 2 deletions test/config/tap.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
jobs: 5
timeout: 60
reporter: spec
coverage: false
disable-coverage: true
allow-empty-coverage: true
node-arg:
- --loader=ts-node/esm
2 changes: 1 addition & 1 deletion test/urls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { readFileSync } from 'node:fs'
import { createServer as createHttpServer } from 'node:http'
import { AddressInfo, createServer } from 'node:net'
import { type AddressInfo, createServer } from 'node:net'
import t from 'tap'
import { info } from '../src/index.js'
import { FastImageError, userAgentVersion } from '../src/models.js'
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
"strictNullChecks": true,
"useUnknownInCatchVariables": false
},
"include": ["src/*.ts"]
"include": [
"src/*.ts"
]
}

0 comments on commit ef79c07

Please sign in to comment.