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

On Windows, the gentimeSettings are written broken to the file because of endent #50

Closed
janpio opened this issue May 20, 2021 · 4 comments · Fixed by #51
Closed

On Windows, the gentimeSettings are written broken to the file because of endent #50

janpio opened this issue May 20, 2021 · 4 comments · Fixed by #51
Labels
type/bug Something is not working the way it should

Comments

@janpio
Copy link

janpio commented May 20, 2021

In #49 unexpectedly the Windows tests fail. Turns out the test project is using an output for the Prisma Client generator which now would be used (correctly) - and for some reason that path is wrong/invalid.

After some local reproduction I found this in .yalc\nexus-prisma\dist\runtime\index.js:

const gentimeSettings = {
  "projectIdIntToGraphQL": "Int",
  "docPropagation": {
    "GraphQLDocs": true,
    "JSDoc": true
  },
  "prismaClientLocation": "C:\\Users\\Jan\\AppData\\Local\\Temp\\9dfe0c5ba27ce64390f947e584e3caeb\
ode_modules\\@prisma\\client"
}

Investigation: #49 (comment)

End result: There seems to be unexpected behavior coming from endent that is used to format that output.

Reproduction:

const endent = require("endent").default;

var string = "c:\\some\\windows\\path\\with\\node_modules\\in\it"

var prettyString = endent`
  before
    ${string}
  after
`;

console.log(string + "\n\n" + prettyString);

You will get the following output:

C:\Users\Jan\Documents\throwaway\ententRepro>node repro.js
c:\some\windows\path\with\node_modules\init

before
  c:\some\windows\path\with
ode_modules\init
after

vs. expected

C:\Users\Jan\Documents\throwaway\ententRepro>node repro.js
c:\some\windows\path\with\node_modules\init

before
  c:\some\windows\path\with\node_modules\init
after
@janpio janpio added the type/bug Something is not working the way it should label May 20, 2021
@janpio janpio changed the title On Windows, the gentimeSettings are wrongly witten to the file because of endent On Windows, the gentimeSettings are written broken to the file because of endent May 20, 2021
@jasonkuhrt
Copy link
Contributor

Quickly looking https://github.com/indentjs/endent/blob/master/src/index.ts I see a lot of potential for not handling \\n there. Going to try moving to another library: https://github.com/tamino-martinius/node-ts-dedent#readme.

@jasonkuhrt
Copy link
Contributor

New library solves the issue:

image

jasonkuhrt added a commit that referenced this issue May 20, 2021
@jasonkuhrt
Copy link
Contributor

But now tamino-martinius/node-ts-dedent#21 fun fun.

@jasonkuhrt
Copy link
Contributor

endent uses dedent https://github.com/indentjs/endent/blob/master/src/index.ts#L58

dedent does this https://github.com/dmnd/dedent/blob/master/dedent.js#L49

that is the bug

My solution was to remove that LOC

Doing so did not break the endent test suite (4 tests...)

It also did not break the NP test suite (more tests, a few dozen)

So there we go, YAL (yet another library) called this time dindist https://github.com/jasonkuhrt/dindist. Made this on my own time technically and it is a small thing so just made it on my account. It is also sloppy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is not working the way it should
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants