-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support cjs and esm both by tshy #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": [ | ||
"eslint-config-egg/typescript", | ||
"eslint-config-egg/lib/rules/enforce-node-prefix" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
Job: | ||
name: Node.js | ||
uses: node-modules/github-actions/.github/workflows/node-test.yml@master | ||
with: | ||
os: 'ubuntu-latest' | ||
version: '18.19.0, 18, 20, 22, 23' | ||
secrets: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Publish Any Commit | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run prepublishOnly --if-present | ||
|
||
- run: npx pkg-pr-new publish |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||||||||||||||
name: Release | ||||||||||||||||||||
|
||||||||||||||||||||
on: | ||||||||||||||||||||
push: | ||||||||||||||||||||
branches: [ master ] | ||||||||||||||||||||
|
||||||||||||||||||||
jobs: | ||||||||||||||||||||
release: | ||||||||||||||||||||
name: Node.js | ||||||||||||||||||||
uses: node-modules/github-actions/.github/workflows/node-release.yml@master | ||||||||||||||||||||
secrets: | ||||||||||||||||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||||||||||||||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | ||||||||||||||||||||
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security: Pin external workflow version and add environment protection
- uses: node-modules/github-actions/.github/workflows/node-release.yml@master
+ uses: node-modules/github-actions/.github/workflows/node-release.yml@v1
+ environment: production
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} 📝 Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ node_modules | |
build | ||
components | ||
coverage | ||
.tshy* | ||
.eslintcache | ||
dist |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2011-2014 fengmk2 | ||
Copyright (c) 2024-present node-modules and the contributors. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,69 @@ | ||
# pedding | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
[![David deps][david-image]][david-url] | ||
[![node version][node-image]][node-url] | ||
[](https://github.com/node-modules/pedding/actions/workflows/nodejs.yml) | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![npm download][download-image]][download-url] | ||
[](https://nodejs.org/en/download/) | ||
[](https://makeapullrequest.com) | ||
|
||
[npm-image]: https://img.shields.io/npm/v/pedding.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/pedding | ||
[travis-image]: https://img.shields.io/travis/node-modules/pedding.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/node-modules/pedding | ||
[coveralls-image]: https://img.shields.io/coveralls/node-modules/pedding.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/node-modules/pedding?branch=master | ||
[gittip-image]: https://img.shields.io/gittip/fengmk2.svg?style=flat-square | ||
[gittip-url]: https://www.gittip.com/fengmk2/ | ||
[david-image]: https://img.shields.io/david/node-modules/pedding.svg?style=flat-square | ||
[david-url]: https://david-dm.org/node-modules/pedding | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square | ||
[node-url]: http://nodejs.org/download/ | ||
[codecov-image]: https://codecov.io/github/node-modules/pedding/coverage.svg?branch=master | ||
[codecov-url]: https://codecov.io/github/node-modules/pedding?branch=master | ||
[download-image]: https://img.shields.io/npm/dm/pedding.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/pedding | ||
|
||
Useful tools for unit test: Just pedding for callback. | ||
Useful tools for unit test: Just pending for callback. | ||
|
||
## Installation | ||
|
||
### Node.js | ||
|
||
```bash | ||
$ npm install pedding | ||
npm install pedding | ||
``` | ||
|
||
### [Component](https://github.com/component/component) | ||
## Usage | ||
|
||
```bash | ||
$ component install node-modules/pedding | ||
CommonJS | ||
|
||
```js | ||
const { pending } = require('pedding'); | ||
|
||
it('should request two resources', done => { | ||
done = pending(2, done); | ||
http.get('http://fengmk2.github.com', res => { | ||
done(); | ||
}); | ||
http.get('http://www.taobao.com', res => { | ||
done(); | ||
}); | ||
}); | ||
``` | ||
|
||
## Usage | ||
ESM and TypeScript | ||
|
||
```js | ||
var pedding = require('pedding'); | ||
```ts | ||
import { pending } from 'pedding'; | ||
|
||
it('should request two resources', function (done) { | ||
done = pedding(2, done); | ||
http.get('http://fengmk2.github.com', function (res) { | ||
it('should request two resources', done => { | ||
done = pending(2, done); | ||
http.get('http://fengmk2.github.com', res => { | ||
done(); | ||
}); | ||
http.get('http://www.taobao.com', function (res) { | ||
http.get('http://www.taobao.com', res => { | ||
done(); | ||
}); | ||
}); | ||
``` | ||
|
||
## License | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2011-2014 fengmk2 <[email protected]> | ||
[MIT](LICENSE) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
## Contributors | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
[](https://github.com/node-modules/pedding/graphs/contributors) | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
Made with [contributors-img](https://contrib.rocks). |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding version tag triggers
The workflow currently triggers on all pushes to master. Consider adding specific version tag triggers to ensure releases only happen for versioned changes.
📝 Committable suggestion