Skip to content

Commit 2c9d6d5

Browse files
authored
feat(plugin-init): generate .gitattributes file (#5205)
* feat(plugin-init): generate .gitattributes file * add version
1 parent 605d0ba commit 2c9d6d5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.yarn/versions/a86095cf.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
releases:
2+
"@yarnpkg/cli": minor
3+
"@yarnpkg/plugin-init": minor
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-interactive-tools"
11+
- "@yarnpkg/plugin-nm"
12+
- "@yarnpkg/plugin-npm-cli"
13+
- "@yarnpkg/plugin-pack"
14+
- "@yarnpkg/plugin-patch"
15+
- "@yarnpkg/plugin-pnp"
16+
- "@yarnpkg/plugin-pnpm"
17+
- "@yarnpkg/plugin-stage"
18+
- "@yarnpkg/plugin-typescript"
19+
- "@yarnpkg/plugin-version"
20+
- "@yarnpkg/plugin-workspace-tools"
21+
- "@yarnpkg/builder"
22+
- "@yarnpkg/core"
23+
- "@yarnpkg/doctor"

packages/plugin-init/sources/commands/init.ts

+17
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,23 @@ export default class InitCommand extends BaseCommand {
198198
changedPaths.push(gitignorePath);
199199
}
200200

201+
const gitattributesLines = [
202+
`/.yarn/** linguist-vendored`,
203+
`/.yarn/releases/* binary`,
204+
`/.yarn/plugins/**/* binary`,
205+
`/.pnp.* binary linguist-generated`,
206+
];
207+
208+
const gitattributesBody = gitattributesLines.map(line => {
209+
return `${line}\n`;
210+
}).join(``);
211+
212+
const gitattributesPath = ppath.join(this.context.cwd, `.gitattributes` as Filename);
213+
if (!xfs.existsSync(gitattributesPath)) {
214+
await xfs.writeFilePromise(gitattributesPath, gitattributesBody);
215+
changedPaths.push(gitattributesPath);
216+
}
217+
201218
const editorConfigProperties = {
202219
[`*`]: {
203220
endOfLine: `lf`,

0 commit comments

Comments
 (0)