Skip to content

Commit 30e8a92

Browse files
committed
feat: add CLI command
fix #27
1 parent 542f7c5 commit 30e8a92

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ but written from scratch to guarantee the same behavior and tidy code as best as
1313
## Usage
1414

1515
```
16-
git clone https://github.com/codemodsquad/asyncify
17-
npx jscodeshift -t asyncify/index.js path/to/your/project/**/*.js
16+
npx @codemodsquad/asyncify path/to/your/project/**/*.js
1817
```
1918

19+
This command just forwards to `jscodeshift`, you can pass other `jscodeshift` CLI options.
20+
2021
## Support table
2122

2223
| | `asyncify` |

bin/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
const child = require('child_process').spawn(
4+
'jscodeshift',
5+
['-t', require.resolve('..'), ...process.argv.slice(2)],
6+
{ stdio: 'inherit' }
7+
)
8+
9+
child.on('error', error => {
10+
// eslint-disable-next-line no-console
11+
console.error(error.stack)
12+
process.exit(1)
13+
})
14+
child.on('close', (code, signal) => {
15+
if (code != 0) {
16+
process.exit(code)
17+
}
18+
if (signal) {
19+
process.exit(1)
20+
}
21+
process.exit(0)
22+
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0-development",
44
"description": "transforms promise chains into async/await",
55
"sideEffects": false,
6+
"bin": "./bin/index.js",
67
"scripts": {
78
"lint": "eslint $npm_package_config_lint",
89
"lint:fix": "eslint $npm_package_config_lint",

0 commit comments

Comments
 (0)