Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ npm install runscript

## Quick start

Commonjs

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

Expand All @@ -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.
Expand All @@ -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');
```
Comment on lines +73 to +81
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Expand the upgrade guide with more details

The upgrade guide could be more comprehensive to help users transition smoothly.

Consider adding:

  1. Breaking changes list
  2. TypeScript type changes (if any)
  3. Example showing both default and named exports usage
  4. Migration steps for different environments (CommonJS, ESM, TypeScript)


## License

[MIT](LICENSE.txt)
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,5 @@ export function runScript(script: string, options: Options = {}, extraOptions: E
}
});
}

export const runscript = runScript;
6 changes: 5 additions & 1 deletion test/runscript.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
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', () => {
it('should run `$ node -v`', () => {
return runScript('node -v');
});

it('should support alias runscript function', () => {
return runscript('node -v');
});

it('should run `$ npm -v`', () => {
return runScript('npm -v');
});
Expand Down
Loading