Skip to content

Commit eb81077

Browse files
authored
feat: support cjs and esm both by tshy (#23)
BREAKING CHANGE: drop Node.js < 14.0.0 support part of eggjs/egg#3644
1 parent eff3960 commit eb81077

File tree

17 files changed

+233
-270
lines changed

17 files changed

+233
-270
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "eslint-config-egg"
2+
"extends": [
3+
"eslint-config-egg/typescript",
4+
"eslint-config-egg/lib/rules/enforce-node-prefix"
5+
]
36
}

.github/workflows/codeql.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/nodejs-14.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Node.js 14 CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Use Node.js
16+
uses: irby/setup-node-nvm@master
17+
with:
18+
node-version: '16.x'
19+
- run: npm install
20+
- run: npm run prepublishOnly
21+
- run: node -v
22+
- run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 && node -v && npm run test:node14

.github/workflows/nodejs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: CI
33
on:
44
push:
55
branches: [ master ]
6-
76
pull_request:
87
branches: [ master ]
98

@@ -13,4 +12,4 @@ jobs:
1312
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
1413
with:
1514
os: 'ubuntu-latest, macos-latest, windows-latest'
16-
version: '8, 10, 12, 14, 16, 18, 20'
15+
version: '16, 18, 20, 22'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ coverage/
1616
test/fixtures/ts/**/*.js
1717
.DS_Store
1818
package-lock.json
19+
.tshy
20+
dist
21+
.eslintcache

README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
runscript
2-
=======
1+
# runscript
32

43
📢📢📢📢📢 You should use [execa](https://github.com/sindresorhus/execa) instead. 📢📢📢📢
54

@@ -22,13 +21,13 @@ Run script easy!
2221
## Installation
2322

2423
```bash
25-
$ npm install runscript
24+
npm install runscript
2625
```
2726

2827
## Quick start
2928

3029
```js
31-
const runScript = require('runscript');
30+
const { runScript } = require('runscript');
3231

3332
runScript('node -v', { stdio: 'pipe' })
3433
.then(stdio => {
@@ -44,7 +43,7 @@ runScript('node -v', { stdio: 'pipe' })
4443
Run user script for a maximum of 10 seconds.
4544

4645
```js
47-
const runScript = require('runscript');
46+
const { runScript } = require('runscript');
4847

4948
runScript('node user-script.js', { stdio: 'pipe' }, { timeout: 10000 })
5049
.then(stdio => {
@@ -59,14 +58,8 @@ runScript('node user-script.js', { stdio: 'pipe' }, { timeout: 10000 })
5958

6059
[MIT](LICENSE.txt)
6160

62-
<!-- GITCONTRIBUTOR_START -->
63-
6461
## Contributors
6562

66-
|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/8433821?v=4" width="100px;"/><br/><sub><b>lusyn</b></sub>](https://github.com/lusyn)<br/>|[<img src="https://avatars.githubusercontent.com/u/9939767?v=4" width="100px;"/><br/><sub><b>walkthunder</b></sub>](https://github.com/walkthunder)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/1622697?v=4" width="100px;"/><br/><sub><b>ottomao</b></sub>](https://github.com/ottomao)<br/>|[<img src="https://avatars.githubusercontent.com/u/227713?v=4" width="100px;"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|
67-
| :---: | :---: | :---: | :---: | :---: | :---: |
68-
[<img src="https://avatars.githubusercontent.com/u/47808321?v=4" width="100px;"/><br/><sub><b>akitaSummer</b></sub>](https://github.com/akitaSummer)<br/>|[<img src="https://avatars.githubusercontent.com/in/17324?v=4" width="100px;"/><br/><sub><b>lgtm-com[bot]</b></sub>](https://github.com/apps/lgtm-com)<br/>|[<img src="https://avatars.githubusercontent.com/u/32174276?v=4" width="100px;"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|[<img src="https://avatars.githubusercontent.com/u/5856440?v=4" width="100px;"/><br/><sub><b>whxaxes</b></sub>](https://github.com/whxaxes)<br/>
69-
70-
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Jan 11 2024 16:25:27 GMT+0800`.
63+
[![Contributors](https://contrib.rocks/image?repo=node-modules/runscript)](https://github.com/node-modules/runscript/graphs/contributors)
7164

72-
<!-- GITCONTRIBUTOR_END -->
65+
Made with [contributors-img](https://contrib.rocks).

index.d.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

package.json

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
"name": "runscript",
33
"version": "1.6.0",
44
"description": "Run script easy!",
5-
"main": "index.js",
6-
"files": [
7-
"index.js",
8-
"index.d.ts"
9-
],
105
"scripts": {
11-
"test": "npm run lint && egg-bin test",
12-
"test-cov": "egg-bin cov",
13-
"lint": "eslint index.js test --fix",
14-
"ci": "npm run lint && npm run test-cov",
15-
"contributor": "git-contributor"
6+
"lint": "eslint --cache src test --ext .ts",
7+
"pretest": "npm run prepublishOnly",
8+
"test": "npm run lint -- --fix && egg-bin test",
9+
"test:node14": "egg-bin test",
10+
"preci": "npm run prepublishOnly",
11+
"ci": "npm run lint && egg-bin cov && attw --pack",
12+
"prepublishOnly": "tshy && tshy-after"
1613
},
1714
"dependencies": {
18-
"is-type-of": "^1.1.0"
15+
"is-type-of": "^2.2.0"
1916
},
2017
"devDependencies": {
21-
"@types/node": "^12.0.8",
18+
"@arethetypeswrong/cli": "^0.15.3",
19+
"@eggjs/tsconfig": "1",
20+
"@types/mocha": "10",
21+
"@types/node": "22",
2222
"autod": "^3.1.2",
23-
"egg-bin": "^1.11.1",
24-
"eslint": "^4.19.1",
25-
"eslint-config-egg": "^6.0.0",
26-
"git-contributor": "^2.1.5",
27-
"typescript": "^3.9.3"
23+
"egg-bin": "6",
24+
"eslint": "8",
25+
"eslint-config-egg": "14",
26+
"tshy": "2",
27+
"tshy-after": "1",
28+
"typescript": "5"
2829
},
2930
"homepage": "https://github.com/node-modules/runscript",
3031
"repository": {
3132
"type": "git",
32-
"url": "git://github.com/node-modules/runscript.git",
33-
"web": "https://github.com/node-modules/runscript"
33+
"url": "git://github.com/node-modules/runscript.git"
3434
},
3535
"bugs": {
3636
"url": "https://github.com/node-modules/runscript/issues"
@@ -41,8 +41,35 @@
4141
"npm run"
4242
],
4343
"engines": {
44-
"node": ">=4.2.3"
44+
"node": ">=16.0.0"
4545
},
4646
"author": "fengmk2 <[email protected]> (https://github.com/fengmk2)",
47-
"license": "MIT"
47+
"license": "MIT",
48+
"type": "module",
49+
"tshy": {
50+
"exports": {
51+
".": "./src/index.ts",
52+
"./package.json": "./package.json"
53+
}
54+
},
55+
"exports": {
56+
".": {
57+
"import": {
58+
"types": "./dist/esm/index.d.ts",
59+
"default": "./dist/esm/index.js"
60+
},
61+
"require": {
62+
"types": "./dist/commonjs/index.d.ts",
63+
"default": "./dist/commonjs/index.js"
64+
}
65+
},
66+
"./package.json": "./package.json"
67+
},
68+
"files": [
69+
"dist",
70+
"src"
71+
],
72+
"types": "./dist/commonjs/index.d.ts",
73+
"main": "./dist/commonjs/index.js",
74+
"module": "./dist/esm/index.js"
4875
}

0 commit comments

Comments
 (0)