Skip to content

Commit e5aa05e

Browse files
committed
fix: code cleanup and fix deps
1 parent ff0cf7e commit e5aa05e

File tree

7 files changed

+18
-61
lines changed

7 files changed

+18
-61
lines changed

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"homepage": "https://github.com/codemodsquad/asyncify#readme",
9595
"devDependencies": {
9696
"@babel/cli": "^7.1.5",
97+
"@babel/core": "^7.1.6",
9798
"@babel/plugin-proposal-class-properties": "^7.1.0",
9899
"@babel/plugin-proposal-export-default-from": "^7.0.0",
99100
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
@@ -142,22 +143,18 @@
142143
"prettier-eslint": "^8.8.2",
143144
"print-highlighted-ast": "^1.0.0",
144145
"promisify-child-process": "^3.1.4",
145-
"recast": "^0.19.0",
146146
"require-glob": "^3.2.0",
147147
"rimraf": "^2.6.0",
148148
"semantic-release": "^15.1.4",
149149
"typescript": "^3.7.2"
150150
},
151151
"dependencies": {
152-
"@babel/core": "^7.1.6",
152+
"@babel/generator": "^7.9.5",
153153
"@babel/runtime": "^7.1.5",
154154
"@babel/template": "^7.8.6",
155155
"@babel/traverse": "^7.9.5",
156156
"@babel/types": "^7.9.5",
157-
"find-root": "^1.1.0",
158-
"invalidate-require-cache": "^1.0.0",
159-
"jscodeshift-choose-parser": "^1.0.1",
160-
"jscodeshift-paths-in-range": "^1.0.0"
157+
"recast": "^0.19.0"
161158
},
162159
"renovate": {
163160
"extends": [

src/asyncify.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ function asyncifyFunction(path: NodePath<t.Function>): void {
1414
path.node.async = true
1515
}
1616
const chains = findPromiseChains(path)
17-
const { ignoreChainsShorterThan } = path.state
1817
for (const chain of chains) {
19-
if (codeLength(chain) < ignoreChainsShorterThan) continue
2018
unwindPromiseChain(chain)
2119
}
2220
if (chains.length || path.node.async) {

src/insertBeforeParentStatement.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/util/findPromiseChains.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as t from '@babel/types'
22
import { NodePath } from '@babel/traverse'
33

44
import { isPromiseMethodCall } from './predicates'
5+
import shouldIgnoreChain from './shouldIgnoreChain'
56

67
export default function findPromiseChains(
78
path: NodePath<t.Function>
@@ -11,7 +12,7 @@ export default function findPromiseChains(
1112
{
1213
CallExpression(path: NodePath<t.CallExpression>) {
1314
if (isPromiseMethodCall(path.node)) {
14-
chains.push(path)
15+
if (!shouldIgnoreChain(path)) chains.push(path)
1516
path.skip()
1617
}
1718
},

src/util/replaceLink.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import renameBoundIdentifiers from './renameBoundIdentifiers'
1111
import unboundIdentifier from './unboundIdentifier'
1212
import replaceReturnStatements from './replaceReturnStatements'
1313
import { awaited } from './builders'
14-
import parentStatement from './parentStatement'
1514
import insertStatementsBefore from './insertStatementsBefore'
1615
import replaceWithStatements from './replaceWithStatements'
1716

src/util/shouldIgnoreChain.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as t from '@babel/types'
2+
import { NodePath } from '@babel/traverse'
3+
import generate from '@babel/generator'
4+
5+
export default function shouldIgnoreChain(
6+
path: NodePath<t.CallExpression>
7+
): boolean {
8+
const { ignoreChainsShorterThan } = path.state
9+
return (
10+
ignoreChainsShorterThan != null &&
11+
generate(path.node as any).code.length < ignoreChainsShorterThan
12+
)
13+
}

yarn.lock

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,11 +3638,6 @@ find-npm-prefix@^1.0.2:
36383638
resolved "https://registry.yarnpkg.com/find-npm-prefix/-/find-npm-prefix-1.0.2.tgz#8d8ce2c78b3b4b9e66c8acc6a37c231eb841cfdf"
36393639
integrity sha512-KEftzJ+H90x6pcKtdXZEPsQse8/y/UnvzRKrOSQFprnrGaFuJ62fVkP34Iu2IYuMvyauCyoLTNkJZgrrGA2wkA==
36403640

3641-
find-root@^1.1.0:
3642-
version "1.1.0"
3643-
resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4"
3644-
integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==
3645-
36463641
find-up@3.0.0, find-up@^3.0.0:
36473642
version "3.0.0"
36483643
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
@@ -4499,11 +4494,6 @@ into-stream@^5.0.0:
44994494
from2 "^2.3.0"
45004495
p-is-promise "^3.0.0"
45014496

4502-
invalidate-require-cache@^1.0.0:
4503-
version "1.0.0"
4504-
resolved "https://registry.yarnpkg.com/invalidate-require-cache/-/invalidate-require-cache-1.0.0.tgz#7be817287ff6adbb6e8e233e7e4a0444af8a540a"
4505-
integrity sha512-3aVHx42pg3GoimLy81TZoLripzJrgaLgABn8itsN2y0n6ykwO39MQO7WdzzUcul02H+FoGg84VD55ovQveXdZg==
4506-
45074497
invariant@^2.2.2, invariant@^2.2.4:
45084498
version "2.2.4"
45094499
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
@@ -5016,22 +5006,6 @@ jsbn@~0.1.0:
50165006
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
50175007
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
50185008

5019-
jscodeshift-choose-parser@^1.0.1:
5020-
version "1.0.1"
5021-
resolved "https://registry.yarnpkg.com/jscodeshift-choose-parser/-/jscodeshift-choose-parser-1.0.1.tgz#90d44ec6d48320ad9c4cb1f5cf7cb3acf220e3d5"
5022-
integrity sha512-t14IztZr4Er6AiejYpV3aEOqry0mWLBpGBv8Jzk7amkSBktELcojT9uxsLZeZIHKcXCtt7bLEOleG+6bCLELhg==
5023-
dependencies:
5024-
find-root "^1.1.0"
5025-
invalidate-require-cache "^1.0.0"
5026-
resolve "^1.15.0"
5027-
5028-
jscodeshift-paths-in-range@^1.0.0:
5029-
version "1.0.0"
5030-
resolved "https://registry.yarnpkg.com/jscodeshift-paths-in-range/-/jscodeshift-paths-in-range-1.0.0.tgz#534f1c95857601f517b144af1d6718a3e2728693"
5031-
integrity sha512-0PFCzk5FLlcpUAbfTXHtsE+MqiSqcEMHII2chVbhliguOFo5oQCKiYLexqYwHXfROycOQf8ZFW3gWUSTpgwa1g==
5032-
dependencies:
5033-
"@babel/runtime" "^7.1.5"
5034-
50355009
jscodeshift@^0.7.0:
50365010
version "0.7.0"
50375011
resolved "https://registry.yarnpkg.com/jscodeshift/-/jscodeshift-0.7.0.tgz#4eee7506fd4fdacbd80340287d61575af991fdab"
@@ -7711,13 +7685,6 @@ resolve@^1.10.0, resolve@^1.12.0, resolve@^1.3.2, resolve@^1.8.1:
77117685
dependencies:
77127686
path-parse "^1.0.6"
77137687

7714-
resolve@^1.15.0:
7715-
version "1.15.1"
7716-
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8"
7717-
integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==
7718-
dependencies:
7719-
path-parse "^1.0.6"
7720-
77217688
restore-cursor@^2.0.0:
77227689
version "2.0.0"
77237690
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"

0 commit comments

Comments
 (0)