-
Notifications
You must be signed in to change notification settings - Fork 38
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(#2628): generate eol LF config #2635
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { | |
type SpawnSyncOptionsWithBufferEncoding, | ||
} from 'node:child_process'; | ||
import { | ||
existsSync, | ||
readFileSync, | ||
writeFileSync, | ||
} from 'node:fs'; | ||
|
@@ -265,6 +266,21 @@ const prepareWorkspace = (relativeDirectory = '.', projectPackageManager = 'npm' | |
} | ||
} | ||
|
||
if (argv.minimal) { | ||
const editorconfigPath = resolve(cwd, '.editorconfig'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it implemented in this file instead of be part of I also think that in any case, as the generators require to be have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me, this file it's part of the monorepo configuration, I would expect to have it defined directly when I create the monorepo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about that @AmadeusITGroup/otter_admins ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also think this should only be generated at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as Florian and Matthieu. I would not mess with an existing project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this is not at all the purpose of the create script. Please remember that the create script is only to initialize a ng repo and start an Otter setup, it should remain as simple as possible and it should not be the one applying guidelines (or setup default value) that would not be available to people who are not generating the repository from scratch with the create. For me the correct behavior is the following one: |
||
const editorconfig = existsSync(editorconfigPath) ? readFileSync(editorconfigPath, { encoding: 'utf8' }) : ''; | ||
const newEditorconfig = /\[[*]\]/.test(editorconfig) | ||
? editorconfig.replace(/(\[[*]\])/, '$1\nend_of_line = lf') | ||
: editorconfig.concat('[*]\nend_of_line = lf'); | ||
writeFileSync(editorconfigPath, newEditorconfig); | ||
} | ||
const gitAttributesPath = resolve(cwd, '.gitattributes'); | ||
writeFileSync( | ||
gitAttributesPath, | ||
(existsSync(gitAttributesPath) ? readFileSync(gitAttributesPath, { encoding: 'utf8' }) : '') | ||
.concat('* text eol=lf') | ||
); | ||
|
||
exitProcessIfErrorInSpawnSync(INSTALL_PROCESS_ERROR_CODE, spawnSync(runner, ['install'], spawnSyncOpts)); | ||
}; | ||
|
||
|
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.
Not sure to understand this option.
If it is needed, you should also provide documentation regarding it in readme.
(and potentially tests :D)
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 is already documented here, you can go on this link https://v17.angular.io/cli/new#options
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.
In their case they are not generating the
.editorconfig
if they have the optionminimal
set to trueThere 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.
This is not really a fare answer :D.
The option itself is not documented but, as part of Angular option, is supported.
I think you can add a comment (with a link potentially) in the code regarding it.
Would be worse to add it as comment as well in the code