Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(patcher.ts): allow lines to be a string again #645

Closed
wants to merge 1 commit into from

Conversation

jedwards1211
Copy link
Contributor

I'm getting errors here when I use print in certain places:

      AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert_1.default.ok(lines instanceof linesModule.Lines)

      + expected - actual

      -false
      +true
      
      at new Patcher (node_modules/recast/lib/patcher.js:28:22)
      at /Users/andy/codemods/node_modules/recast/lib/patcher.js:149:23
      at print (node_modules/recast/lib/printer.js:86:15)
      at /Users/andy/codemods/node_modules/recast/lib/printer.js:58:20
      at Object.printComments (node_modules/recast/lib/comments.js:283:22)
      at print (node_modules/recast/lib/printer.js:65:31)
      at Printer.print (node_modules/recast/lib/printer.js:98:21)
      at Object.print (node_modules/recast/main.js:39:43)
      at print (test/graphqlToFlowTest.js:130:25)
      at c (node_modules/lodash/lodash.min.js:6:348)
      at Function.ru (node_modules/lodash/lodash.min.js:67:252)
      at t (node_modules/lodash/lodash.min.js:131:335)
      at Qe (node_modules/lodash/lodash.min.js:67:92)
      at /Users/andy/codemods/node_modules/lodash/lodash.min.js:41:394
      at l (node_modules/lodash/lodash.min.js:6:528)
      at wr (node_modules/lodash/lodash.min.js:41:362)
      at Un.value (node_modules/lodash/lodash.min.js:134:528)
      at wr (node_modules/lodash/lodash.min.js:41:353)
      at On.An.toJSON.An.valueOf.An.value (node_modules/lodash/lodash.min.js:136:453)
      at /Users/andy/codemods/node_modules/lodash/lodash.min.js:49:85
      at pipeline (src/pipeline.js:3:38)
      at Context.<anonymous> (test/graphqlToFlowTest.js:124:20)

Looking at the code, I'm pretty sure the whoever wrote the assertions wasn't thinking about the isString check below.

I'm getting errors here when I use print in certain places:
```
      AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert_1.default.ok(lines instanceof linesModule.Lines)

      + expected - actual

      -false
      +true
      
      at new Patcher (node_modules/recast/lib/patcher.js:28:22)
      at /Users/andy/codemods/node_modules/recast/lib/patcher.js:149:23
      at print (node_modules/recast/lib/printer.js:86:15)
      at /Users/andy/codemods/node_modules/recast/lib/printer.js:58:20
      at Object.printComments (node_modules/recast/lib/comments.js:283:22)
      at print (node_modules/recast/lib/printer.js:65:31)
      at Printer.print (node_modules/recast/lib/printer.js:98:21)
      at Object.print (node_modules/recast/main.js:39:43)
      at print (test/graphqlToFlowTest.js:130:25)
      at c (node_modules/lodash/lodash.min.js:6:348)
      at Function.ru (node_modules/lodash/lodash.min.js:67:252)
      at t (node_modules/lodash/lodash.min.js:131:335)
      at Qe (node_modules/lodash/lodash.min.js:67:92)
      at /Users/andy/codemods/node_modules/lodash/lodash.min.js:41:394
      at l (node_modules/lodash/lodash.min.js:6:528)
      at wr (node_modules/lodash/lodash.min.js:41:362)
      at Un.value (node_modules/lodash/lodash.min.js:134:528)
      at wr (node_modules/lodash/lodash.min.js:41:353)
      at On.An.toJSON.An.valueOf.An.value (node_modules/lodash/lodash.min.js:136:453)
      at /Users/andy/codemods/node_modules/lodash/lodash.min.js:49:85
      at pipeline (src/pipeline.js:3:38)
      at Context.<anonymous> (test/graphqlToFlowTest.js:124:20)
```

Looking at the code, I'm pretty sure the whoever wrote the assertions wasn't thinking about the `isString` check below.
@jedwards1211
Copy link
Contributor Author

jedwards1211 commented Oct 16, 2019

nevermind maybe...the problem was that I wound up with dupe versions of recast after pinning to 0.18.4 since jscodeshift is behind on upgrading recast (as always non-semver 0.x versions cause really annoying problems, no one should be afraid of releasing experimental stuff as 1.0.0 and then bumping the major version whenever)

@eventualbuddha
Copy link
Collaborator

Ah, yeah duplicate versions of recast will definitely cause issues with the instanceof checks. If you're using Yarn you can force it to resolve a specific version of recast:

"resolutions": {
  "**/recast": "0.18.5"
}

There might be some way to do that with NPM but I'm not sure what it is.

Also, the isString check you alluded to in your original post is inside the replace instance method so I don't think it applies.

@jedwards1211
Copy link
Contributor Author

oh thanks for that tip! I didn't realize I could use **/ in resolutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants