Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "appium"
"extends": ["@appium/eslint-config-appium-ts"]
}
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "11:00"
open-pull-requests-limit: 10
commit-message:
prefix: "chore"
include: "scope"
15 changes: 15 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Conventional Commits
on:
pull_request:


jobs:
lint:
name: https://www.conventionalcommits.org
runs-on: ubuntu-latest
steps:
- uses: beemojs/conventional-pr-action@v2
with:
config-preset: angular
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Unit Tests

on: [pull_request, push]


jobs:
prepare_matrix:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.generate-matrix.outputs.versions }}
steps:
- name: Select 3 most recent LTS versions of Node.js
id: generate-matrix
run: echo "versions=$(curl -s https://endoflife.date/api/nodejs.json | jq -c '[[.[] | select(.lts != false)][:3] | .[].cycle | tonumber]')" >> "$GITHUB_OUTPUT"

test:
needs:
- prepare_matrix
strategy:
matrix:
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install --no-package-lock
name: Install dev dependencies
- run: npm run lint
name: Run linter
- run: npm run test
name: Run unit tests
4 changes: 4 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
require: ['ts-node/register'],
forbidOnly: Boolean(process.env.CI)
};
8 changes: 0 additions & 8 deletions gulpfile.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/asyncbox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// transpile:main

import B from 'bluebird';
import _ from 'lodash';

Expand Down
48 changes: 28 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"url": "https://github.com/jlipps/asyncbox/issues"
},
"engines": {
"node": ">=10"
"node": ">=16"
},
"main": "./build/lib/asyncbox.js",
"bin": {},
Expand All @@ -29,33 +29,41 @@
"build/lib/**/*"
],
"dependencies": {
"@babel/runtime": "^7.0.0",
"bluebird": "^3.5.1",
"lodash": "^4.17.4",
"source-map-support": "^0.5.5",
"@types/bluebird": "^3.5.37"
"source-map-support": "^0.x"
},
"scripts": {
"clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
"prepare": "gulp prepublish && tsc",
"test": "gulp once",
"e2e-test": "gulp e2e-test",
"build": "gulp transpile && tsc",
"lint": "gulp eslint",
"watch": "gulp watch"
"build": "tsc -b",
"clean": "npm run build -- --clean",
"rebuild": "npm run clean; npm run build",
"dev": "npm run build -- --watch",
"prepare": "npm run rebuild",
"test": "mocha --exit --timeout 1m \"./test/**/*-specs.js\"",
"lint": "eslint .",
"watch": "npm run dev"
},
"devDependencies": {
"@appium/eslint-config-appium": "^8.0.4",
"@appium/eslint-config-appium-ts": "^0.x",
"@appium/tsconfig": "^0.x",
"@types/bluebird": "^3.5.37",
"@types/lodash": "^4.14.189",
"ajv": "^6.5.3",
"appium-gulp-plugins": "^4.0.0",
"chai": "4.2.0",
"@types/node": "^20.4.7",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint-config-appium": "^4.0.0",
"gulp": "^4.0.0",
"request": "^2.47.0",
"should": "^13.2.1",
"sinon": "^11.1.2",
"typescript": "~4.7.0"
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-promise": "^6.1.1",
"mocha": "^10.0.0",
"sinon": "^16.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"types": "./build/lib/asyncbox.d.ts"
}
16 changes: 8 additions & 8 deletions test/asyncbox-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('retry', function () {
eventuallyOkFnCalls.should.equal(3);
res.should.equal(9);
// XXX: flaky
(Date.now() - start).should.be.above(30);
(Date.now() - start).should.be.least(30);
});
it('should not wait on the final error', async function () {
const start = Date.now();
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('nodeifyAll', function () {
should.not.exist(err);
should.not.exist(val2);
val.should.equal('foo');
(Date.now() - start).should.be.above(14);
(Date.now() - start).should.be.least(14);
done();
});
});
Expand All @@ -192,7 +192,7 @@ describe('nodeifyAll', function () {
should.not.exist(err);
should.not.exist(val2);
val.should.equal('foo');
(Date.now() - start).should.be.above(14);
(Date.now() - start).should.be.least(14);
done();
});
});
Expand All @@ -201,7 +201,7 @@ describe('nodeifyAll', function () {
nodeify(asyncFn2('foo'), function (err, val) { // eslint-disable-line promise/prefer-await-to-callbacks
should.not.exist(err);
val.should.eql(['foo', 'foofoo']);
(Date.now() - start).should.be.above(14);
(Date.now() - start).should.be.least(14);
done();
});
});
Expand All @@ -210,7 +210,7 @@ describe('nodeifyAll', function () {
nodeify(badAsyncFn('foo'), function (err, val) { // eslint-disable-line promise/prefer-await-to-callbacks
should.not.exist(val);
err.message.should.equal('boo');
(Date.now() - start).should.be.above(14);
(Date.now() - start).should.be.least(14);
done();
});
});
Expand Down Expand Up @@ -307,7 +307,7 @@ describe('parallel', function () {
}
await (waitForCondition(condFn, {waitMs: 20, intervalMs: 10}));
let getLastCall = requestSpy.getCall(1);
getLastCall.args[0].should.be.below(10);
getLastCall.args[0].should.be.most(10);
});
});
});
Expand All @@ -321,12 +321,12 @@ describe('asyncmap', function () {
it('should map elements one at a time', async function () {
let start = Date.now();
(await asyncmap(coll, mapper, false)).should.eql([2, 4, 6]);
(Date.now() - start).should.be.above(30);
(Date.now() - start).should.be.least(30);
});
it('should map elements in parallel', async function () {
let start = Date.now();
(await asyncmap(coll, mapper)).should.eql([2, 4, 6]);
(Date.now() - start).should.be.below(20);
(Date.now() - start).should.be.most(20);
});
it('should handle an empty array', async function () {
(await asyncmap([], mapper, false)).should.eql([]);
Expand Down
20 changes: 9 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@appium/tsconfig/tsconfig.json",
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"esModuleInterop": true,
"strict": true,
"allowJs": true,
"checkJs": true,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"moduleResolution": "node",
"outDir": "build/lib"
"strict": false,
"outDir": "build",
"types": ["node"],
"checkJs": true
},
"include": ["lib"]
"include": [
"lib"
]
}