From 70395b27f10d72c3e0406eadc6a6dc42abeeb464 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 10 Dec 2024 10:18:16 +0800 Subject: [PATCH 1/2] fix: export runscript function (#24) --- README.md | 26 ++++++++++++++++++++++++++ src/index.ts | 2 ++ test/runscript.test.ts | 6 +++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 97e384f..738cfda 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ npm install runscript ## Quick start +Commonjs + ```js const { runScript } = require('runscript'); @@ -38,6 +40,20 @@ runScript('node -v', { stdio: 'pipe' }) }); ``` +ESM & TypeScript + +```js +import { runScript } from 'runscript'; + +runScript('node -v', { stdio: 'pipe' }) + .then(stdio => { + console.log(stdio); + }) + .catch(err => { + console.error(err); + }); +``` + ### run with timeout Run user script for a maximum of 10 seconds. @@ -54,6 +70,16 @@ runScript('node user-script.js', { stdio: 'pipe' }, { timeout: 10000 }) }); ``` +## Upgrade from 1.x to 2.x + +```js +// 1.x +// const runscript = require('runscript'); + +// 2.x +const { runscript } = require('runscript'); +``` + ## License [MIT](LICENSE.txt) diff --git a/src/index.ts b/src/index.ts index c7bc0cc..cb8fc17 100644 --- a/src/index.ts +++ b/src/index.ts @@ -202,3 +202,5 @@ export function runScript(script: string, options: Options = {}, extraOptions: E } }); } + +export const runscript = runScript; diff --git a/test/runscript.test.ts b/test/runscript.test.ts index c4d3dea..1529112 100644 --- a/test/runscript.test.ts +++ b/test/runscript.test.ts @@ -1,6 +1,6 @@ import fs from 'node:fs'; import { strict as assert } from 'node:assert'; -import { runScript, RunScriptTimeoutError } from '../src/index.js'; +import { runscript, runScript, RunScriptTimeoutError } from '../src/index.js'; import { getFixtures } from './helper.js'; describe('test/runscript.test.ts', () => { @@ -8,6 +8,10 @@ describe('test/runscript.test.ts', () => { return runScript('node -v'); }); + it('should support alias runscript function', () => { + return runscript('node -v'); + }); + it('should run `$ npm -v`', () => { return runScript('npm -v'); }); From 8c2c16b8e9166fbee06c54f0ca5bc3afe932cc58 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 10 Dec 2024 02:21:21 +0000 Subject: [PATCH 2/2] Release 2.0.1 [skip ci] ## [2.0.1](https://github.com/node-modules/runscript/compare/v2.0.0...v2.0.1) (2024-12-10) ### Bug Fixes * export runscript function ([#24](https://github.com/node-modules/runscript/issues/24)) ([70395b2](https://github.com/node-modules/runscript/commit/70395b27f10d72c3e0406eadc6a6dc42abeeb464)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84fbd4c..5df4c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [2.0.1](https://github.com/node-modules/runscript/compare/v2.0.0...v2.0.1) (2024-12-10) + + +### Bug Fixes + +* export runscript function ([#24](https://github.com/node-modules/runscript/issues/24)) ([70395b2](https://github.com/node-modules/runscript/commit/70395b27f10d72c3e0406eadc6a6dc42abeeb464)) + ## [2.0.0](https://github.com/node-modules/runscript/compare/v1.6.0...v2.0.0) (2024-12-09) diff --git a/package.json b/package.json index 0a9a105..2dd876e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "runscript", - "version": "2.0.0", + "version": "2.0.1", "description": "Run script easy!", "scripts": { "lint": "eslint --cache src test --ext .ts",