https://github.com/futagoza/runasync
Run a script that exports an async function
https://github.com/futagoza/runasync
async nodejs promise script
Last synced: 10 months ago
JSON representation
Run a script that exports an async function
- Host: GitHub
- URL: https://github.com/futagoza/runasync
- Owner: futagoza
- License: mit
- Created: 2017-07-02T12:21:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-27T18:40:55.000Z (over 8 years ago)
- Last Synced: 2025-03-09T22:35:27.057Z (11 months ago)
- Topics: async, nodejs, promise, script
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/runasync)
[](https://opensource.org/licenses/MIT)
This is a simple module to execute a JavaScript file that exports (as a default)
a ES2017 `async` function (or a function that returns a ES2015 `Promise`).
To use `async` function's you must have Node.js v7.6.0 or higher, where as for native
support for Promise's requires Node.js v4.0.0
## installation
```bash
$ npm i runasync
```
## usage
#### programmatically via `require()`
```js
const runAsyncFile = require( "runasync" );
async function main() {
const run = await runAsyncFile( "./async-app"/*[, optionalArgs], optionalCallback*/ );
run.result // the returned result, if any (as long as there was no error)
run.error // if there was an error, this is where you'de find it
}
```
#### via the cli
```bash
$ runasync ./async-app arg1 arg2
```
## why?
1. Simply for the ease of executing an async method via the cli and having its error thrown to the console in a cleaner manner instead of also receiving a `unhandled` error from Node.js and/or the Promise.
2. A simpler way to chain script tasks together, rather then calling `require( "child_process" ).spawn`
## license
runasync is maintained by [Futago-za Ryuu](https://futagoza.github.io/)
Released under [the MIT License](http://opensource.org/licenses/MIT)