-
-
Notifications
You must be signed in to change notification settings - Fork 382
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(core): Fixed workspace setting does not append a newline to the end of a line in an existing index file #1875 #1876
fix(core): Fixed workspace setting does not append a newline to the end of a line in an existing index file #1875 #1876
Conversation
81c3a45
to
06fad3b
Compare
…nd of a line in an existing index file (orval-labs#1875)
06fad3b
to
419fa48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maroKanatani
Thank you for the nice update. I made one change request and a question
packages/orval/src/write-specs.ts
Outdated
.map((imp) => `export * from '${imp}';\n`) | ||
.join(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be aligned with the pattern written in else.
orval/packages/orval/src/write-specs.ts
Lines 139 to 144 in 419fa48
await fs.outputFile( | |
indexFile, | |
uniq(imports) | |
.map((imp) => `export * from '${imp}';`) | |
.join('\n') + '\n', | |
); |
.map((imp) => `export * from '${imp}';\n`) | |
.join(), | |
.map((imp) => `export * from '${imp}';`) | |
.join('\n'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a little worried that if I implemented it with .join('\n')
, the last line would not have a newline.
"export * from './zod/pet/pet';\n" +
"export * from './zod/store/store';\n" +
"export * from './zod/user/user';\n" +
+"export * from './types';\n" // my pattern
-"export * from './types';" // with `.join('\n')`
With .join('\n') + '\n'
before the modification, a newline is inserted even if the result of uniq(imports) is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. You're right.
@@ -132,8 +132,8 @@ export const writeSpecs = async ( | |||
await fs.appendFile( | |||
indexFile, | |||
uniq(importsNotDeclared) | |||
.map((imp) => `export * from '${imp}';`) | |||
.join('\n') + '\n', | |||
.map((imp) => `export * from '${imp}';\n`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is already a newline at the end, will a new definition be added below that newline?
In that case, you may need to first remove the original trailing newline and then add another trailing newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is already a newline at the end, will a new definition be added below that newline?
No, the behavior appears to be the same, especially before this modification.
No, the behavior does not seem to change, especially before this modification.
I have confirmed that it is appended by preparing and executing petstore index.ts with a new line at the end as shown below.
before
export * from './zod/user/user';
export * from './types';
export * from './zod/store/store';
- export * from './zod/pet/pet'; // remove this line
after
export * from './zod/user/user';
export * from './types';
export * from './zod/store/store';
+ export * from './zod/pet/pet';
@soartec-lab Thanks for the review! I have returned your comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Status
READY
Description
Fixed workspace setting does not append a newline to the end of a line in an existing index file.
I don't know the details of the code, so if you think another way is better or whatever, you can close this PR.
Related PRs
List related PRs against other branches:
Todos
Steps to Test or Reproduce
Please follow the steps in the following Issue