Skip to content

Commit

Permalink
chore: Add tooling for code coverage, changelogs, and conventional co…
Browse files Browse the repository at this point in the history
…mmits (#10)

*  rename license
* setup codecov and badges
*  commitlint and standard version setup
* upgrade to grumbler-scripts v5
  • Loading branch information
westeezy committed Feb 27, 2022
1 parent 7a59a2a commit 8de3269
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 46 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ jobs:
with:
useLockFile: false

- name: 👕 Lint commit messages
uses: wagoid/commitlint-github-action@v4

- name: ▶️ Run flow-typed script
run: npm run flow-typed

- name: ▶️ Run build script
run: npm run build

- name: ⬆️ Upload karma coverage report
uses: codecov/codecov-action@v2
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
File renamed without changes.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
zalgo-promise
-------------

[![build status][build-badge]][build]
[![code coverage][coverage-badge]][coverage]
[![npm version][version-badge]][package]

[build-badge]: https://img.shields.io/github/workflow/status/krakenjs/zalgo-promise/build?logo=github&style=flat-square
[build]: https://github.com/krakenjs/zalgo-promise/actions?query=workflow%3Abuild
[coverage-badge]: https://img.shields.io/codecov/c/github/krakenjs/zalgo-promise.svg?style=flat-square
[coverage]: https://codecov.io/github/krakenjs/zalgo-promise/
[version-badge]: https://img.shields.io/npm/v/zalgo-promise.svg?style=flat-square
[package]: https://www.npmjs.com/package/zalgo-promise

Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* @flow */
/* eslint import/no-commonjs: off */

module.exports = {
extends: [ '@commitlint/config-conventional' ]
};
58 changes: 51 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,53 @@
"webpack": "babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --display-optimization-bailout --progress",
"test": "npm run lint && npm run flow-typed && npm run flow && npm run karma",
"build": "npm run test && npm run babel && npm run webpack",
"release": "./publish.sh",
"release:patch": "./publish.sh patch",
"release:minor": "./publish.sh minor",
"release:major": "./publish.sh major",
"clean": "rimraf dist coverage",
"reinstall": "rimraf flow-typed && rimraf node_modules && npm install && flow-typed install",
"debug": "cross-env NODE_ENV=debug"
"debug": "cross-env NODE_ENV=debug",
"prepare": "husky install",
"prerelease": "npm run clean && npm run build && git add dist && git commit -m 'ci: check in dist folder' || echo 'Nothing to distribute'",
"release": "standard-version",
"postrelease": "git push && git push --follow-tags && npm publish"
},
"standard-version": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"hidden": false
},
{
"type": "docs",
"hidden": false
},
{
"type": "style",
"hidden": false
},
{
"type": "refactor",
"hidden": false
},
{
"type": "perf",
"hidden": false
},
{
"type": "test",
"hidden": false
},
{
"type": "ci",
"hidden": true
}
]
},
"repository": {
"type": "git",
Expand All @@ -40,9 +80,13 @@
],
"readmeFilename": "README.md",
"devDependencies": {
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"flow-bin": "0.155.0",
"grumbler-scripts": "^3",
"mocha": "^4"
"grumbler-scripts": "^5.0.3",
"husky": "^7.0.4",
"mocha": "^4",
"standard-version": "^9.3.2"
},
"dependencies": {}
}
27 changes: 0 additions & 27 deletions publish.sh

This file was deleted.

25 changes: 13 additions & 12 deletions src/promise.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
/* @flow */
/* eslint no-use-before-define: off */

import { isPromise } from './utils';
import { onPossiblyUnhandledException, dispatchPossiblyUnhandledError } from './exceptions';
import { startActive, endActive, awaitActive } from './flush';

export class ZalgoPromise<R : mixed> {

resolved : boolean
rejected : boolean
errorHandled : boolean
value : R
error : mixed
resolved : boolean;
rejected : boolean;
errorHandled : boolean;
value : R;
error : mixed;
// eslint-disable-next-line flowtype/no-mutable-array
handlers : Array<{|
promise : ZalgoPromise<*>,
onSuccess : void | (result : R) => mixed,
onError : void | (error : mixed) => mixed
|}>
dispatching : boolean
stack : string
|}>;
dispatching : boolean;
stack : string;

constructor(handler : ?(resolve : (result : R) => void, reject : (error : mixed) => void) => void) {

Expand Down Expand Up @@ -135,7 +136,7 @@ export class ZalgoPromise<R : mixed> {
this.reject(error);
return this;
}

dispatch() {

const { dispatching, resolved, rejected, handlers } = this;
Expand Down Expand Up @@ -340,7 +341,7 @@ export class ZalgoPromise<R : mixed> {

const promise = new ZalgoPromise();
let count = promises.length;
// eslint-disable-next-line no-undef
// eslint-disable-next-line no-undef, unicorn/prefer-spread
const results = ([] : $TupleMap<X, <Y>(ZalgoPromise<Y> | Y) => Y>).slice();

if (!count) {
Expand Down Expand Up @@ -402,7 +403,7 @@ export class ZalgoPromise<R : mixed> {
}
}
}

return ZalgoPromise.all(awaitPromises).then(() => result);
}

Expand All @@ -424,7 +425,7 @@ export class ZalgoPromise<R : mixed> {
let result : ZalgoPromise<X> | Y;

startActive();

try {
result = method.apply(context, args || []);
} catch (err) {
Expand Down

0 comments on commit 8de3269

Please sign in to comment.