Skip to content

Commit

Permalink
feat: support cjs and esm both by tshy (#23)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop Node.js < 14.0.0 support

part of eggjs/egg#3644
  • Loading branch information
fengmk2 authored Dec 9, 2024
1 parent eff3960 commit eb81077
Show file tree
Hide file tree
Showing 17 changed files with 233 additions and 270 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "eslint-config-egg"
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
39 changes: 0 additions & 39 deletions .github/workflows/codeql.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/nodejs-14.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Node.js 14 CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: irby/setup-node-nvm@master
with:
node-version: '16.x'
- run: npm install
- run: npm run prepublishOnly
- run: node -v
- run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 && node -v && npm run test:node14
3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: CI
on:
push:
branches: [ master ]

pull_request:
branches: [ master ]

Expand All @@ -13,4 +12,4 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest, windows-latest'
version: '8, 10, 12, 14, 16, 18, 20'
version: '16, 18, 20, 22'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ coverage/
test/fixtures/ts/**/*.js
.DS_Store
package-lock.json
.tshy
dist
.eslintcache
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
runscript
=======
# runscript

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

Expand All @@ -22,13 +21,13 @@ Run script easy!
## Installation

```bash
$ npm install runscript
npm install runscript
```

## Quick start

```js
const runScript = require('runscript');
const { runScript } = require('runscript');

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

```js
const runScript = require('runscript');
const { runScript } = require('runscript');

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

[MIT](LICENSE.txt)

<!-- GITCONTRIBUTOR_START -->

## Contributors

|[<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/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
[<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/>

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`.
[![Contributors](https://contrib.rocks/image?repo=node-modules/runscript)](https://github.com/node-modules/runscript/graphs/contributors)

<!-- GITCONTRIBUTOR_END -->
Made with [contributors-img](https://contrib.rocks).
26 changes: 0 additions & 26 deletions index.d.ts

This file was deleted.

69 changes: 48 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
"name": "runscript",
"version": "1.6.0",
"description": "Run script easy!",
"main": "index.js",
"files": [
"index.js",
"index.d.ts"
],
"scripts": {
"test": "npm run lint && egg-bin test",
"test-cov": "egg-bin cov",
"lint": "eslint index.js test --fix",
"ci": "npm run lint && npm run test-cov",
"contributor": "git-contributor"
"lint": "eslint --cache src test --ext .ts",
"pretest": "npm run prepublishOnly",
"test": "npm run lint -- --fix && egg-bin test",
"test:node14": "egg-bin test",
"preci": "npm run prepublishOnly",
"ci": "npm run lint && egg-bin cov && attw --pack",
"prepublishOnly": "tshy && tshy-after"
},
"dependencies": {
"is-type-of": "^1.1.0"
"is-type-of": "^2.2.0"
},
"devDependencies": {
"@types/node": "^12.0.8",
"@arethetypeswrong/cli": "^0.15.3",
"@eggjs/tsconfig": "1",
"@types/mocha": "10",
"@types/node": "22",
"autod": "^3.1.2",
"egg-bin": "^1.11.1",
"eslint": "^4.19.1",
"eslint-config-egg": "^6.0.0",
"git-contributor": "^2.1.5",
"typescript": "^3.9.3"
"egg-bin": "6",
"eslint": "8",
"eslint-config-egg": "14",
"tshy": "2",
"tshy-after": "1",
"typescript": "5"
},
"homepage": "https://github.com/node-modules/runscript",
"repository": {
"type": "git",
"url": "git://github.com/node-modules/runscript.git",
"web": "https://github.com/node-modules/runscript"
"url": "git://github.com/node-modules/runscript.git"
},
"bugs": {
"url": "https://github.com/node-modules/runscript/issues"
Expand All @@ -41,8 +41,35 @@
"npm run"
],
"engines": {
"node": ">=4.2.3"
"node": ">=16.0.0"
},
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
"license": "MIT"
"license": "MIT",
"type": "module",
"tshy": {
"exports": {
".": "./src/index.ts",
"./package.json": "./package.json"
}
},
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
},
"./package.json": "./package.json"
},
"files": [
"dist",
"src"
],
"types": "./dist/commonjs/index.d.ts",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js"
}
Loading

0 comments on commit eb81077

Please sign in to comment.