Skip to content

Commit

Permalink
feat: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 13, 2022
1 parent c3e61ce commit 4a25d12
Show file tree
Hide file tree
Showing 4 changed files with 2,013 additions and 3,040 deletions.
24 changes: 15 additions & 9 deletions package.json
Expand Up @@ -4,39 +4,45 @@
"description": "",
"repository": "unjs/listhen",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "siroc build",
"build": "unbuild",
"dev": "jiti test/fixture/app",
"lint": "eslint --ext .ts .",
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
},
"dependencies": {
"clipboardy": "^2.3.0",
"colorette": "^1.2.2",
"clipboardy": "^3.0.0",
"colorette": "^2.0.16",
"defu": "^5.0.0",
"get-port-please": "^2.1.0",
"http-shutdown": "^1.2.2",
"open": "^8.0.5",
"selfsigned": "^1.10.8"
"selfsigned": "^2.0.0"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"@types/cheerio": "^0.22.22",
"@types/cheerio": "latest",
"@types/flat": "latest",
"@types/jest": "latest",
"@types/node": "latest",
"eslint": "latest",
"jest": "latest",
"jiti": "latest",
"siroc": "latest",
"standard-version": "latest",
"ts-jest": "latest",
"typescript": "latest"
"typescript": "latest",
"unbuild": "latest"
}
}
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -100,7 +100,7 @@ export async function listen (handle: http.RequestListener, opts: Partial<Listen
}

if (opts.clipboard) {
const clipboardy = await import('clipboardy')
const clipboardy = await import('clipboardy').then(r => r.default || r)
await clipboardy.write(url).catch(() => { opts.clipboard = false })
}

Expand Down
21 changes: 5 additions & 16 deletions test/index.test.ts
@@ -1,11 +1,7 @@
// @ts-nocheck
import './setup'
import { resolve } from 'path'
import { listen } from '../src'

jest.mock('clipboardy')
const clipboardy = require('clipboardy')
clipboardy.write = jest.fn().mockImplementation(() => Promise.resolve())
import type { IncomingMessage, ServerResponse } from 'http'
import { listen, Listener } from '../src'

jest.mock('open')
const open = require('open')
Expand All @@ -14,12 +10,12 @@ open.mockImplementation(() => Promise.resolve())
// eslint-disable-next-line no-console
console.log = jest.fn()

function handle (req, res) {
function handle (req: IncomingMessage, res: ServerResponse) {
res.end(req.url)
}

describe('listhen', () => {
let listener
let listener: Listener | null

afterEach(async () => {
if (listener) {
Expand All @@ -37,7 +33,6 @@ describe('listhen', () => {
listener = await listen(handle, {
isTest: false,
autoClose: false,
clipboard: true,
open: true,
baseURL: '/foo/bar'
})
Expand All @@ -63,14 +58,8 @@ describe('listhen', () => {
expect(listener.url.startsWith('https://')).toBe(true)
})

test('silent errors', async () => {
clipboardy.write.mockImplementationOnce(() => Promise.reject(new Error('Error')))
open.mockImplementationOnce(() => Promise.reject(new Error('Error')))
listener = await listen(handle, { isTest: false, clipboard: true, open: true })
})

test('double close', async () => {
listener = await listen(handle, { isTest: false, clipboard: true, open: true })
listener = await listen(handle, { isTest: false, open: true })
await listener.close()
await listener.close()
})
Expand Down

0 comments on commit 4a25d12

Please sign in to comment.