Skip to content

Commit

Permalink
feat: bump busboy version to v1 (#2)
Browse files Browse the repository at this point in the history
* chore: bump busboy to version 1.6.0

* fix: node version list should follow busboy requirements
  • Loading branch information
fatwong committed Jun 20, 2022
1 parent d4409d9 commit dedba8e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 51 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
pull_request:
push:
branches: [ master ]

jobs:
tests-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [10.16.0, 10.x, 12.x, 14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install module
run: npm install
- name: Run tests
run: npm test
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: lint

on:
pull_request:
push:
branches: [ master ]

env:
NODE_VERSION: 16.x

jobs:
lint-js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install ESLint + ESLint configs/plugins
run: npm install --only=dev
- name: Lint files
run: npm run lint
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = (request, options) => {
const checkFile = options.checkFile
let lastError

const busboy = new Busboy(options)
const busboy = Busboy(options)

request.on('close', cleanup)

Expand All @@ -37,7 +37,7 @@ module.exports = (request, options) => {
.on('file', onFile)
.on('close', cleanup)
.on('error', onEnd)
.on('finish', onEnd)
.on('close', onEnd)

busboy.on('partsLimit', () => {
const err = new Error('Reach parts limit')
Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports = (request, options) => {

return res

function onField (name, val, fieldnameTruncated, valTruncated) {
function onField (name, val, { nameTruncated: fieldnameTruncated, valueTruncated: valTruncated }) {
if (checkField) {
const err = checkField(name, val, fieldnameTruncated, valTruncated)
if (err) {
Expand Down Expand Up @@ -103,7 +103,7 @@ module.exports = (request, options) => {
}
}

function onFile (fieldname, file, filename, encoding, mimetype) {
function onFile (fieldname, file, { filename, encoding, mime: mimetype }) {
if (checkFile) {
const err = checkFile(fieldname, file, filename, encoding, mimetype)
if (err) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"url": "https://github.com/aheckmann/await-busboy/issues"
},
"engines": {
"node": ">= 7.6.0"
"node": ">= 10.16.0"
},
"dependencies": {
"black-hole-stream": "0.0.1",
"busboy": "0.3.0"
"busboy": "1.6.0"
},
"devDependencies": {
"co": "4.6.x",
Expand Down
17 changes: 1 addition & 16 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
'use strict'

const vm = require('vm')

function hasAsyncSupport () {
try {
vm.runInNewContext('async () => {}')
} catch (err) {
return false
}

return true
}

// tests

require('./co-busboy.js')
require('./result.js')

if (hasAsyncSupport()) {
require('./async.js')
}
require('./async.js')
13 changes: 1 addition & 12 deletions test/result.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
/* global it, describe */
'use strict'

const vm = require('vm')
const assert = require('assert')
const Result = require('../result')

let inspectPromise = (p) => {
const Debug = vm.runInDebugContext('Debug') // eslint-disable-line
const mirror = Debug.MakeMirror(p, true)
return mirror.status()
}

describe('Result', function () {
it('is a constructor', function (done) {
assert.strictEqual('function', typeof Result)
Expand Down Expand Up @@ -96,8 +89,6 @@ describe('Result', function () {
}).catch(done)

assert(p instanceof Promise)
const status = inspectPromise(p)
assert.strictEqual('pending', status)

setTimeout(() => {
ranInOrder = true
Expand Down Expand Up @@ -246,11 +237,9 @@ describe('Result', function () {
function test2 (val) {
assert.strictEqual('two', val)

const p3 = res.then(test3).catch(done)
res.then(test3).catch(done)

setTimeout(() => {
const status = inspectPromise(p3)
assert.strictEqual('pending', status)
res.add(47)
}, 80)
}
Expand Down

0 comments on commit dedba8e

Please sign in to comment.