Skip to content

Commit 76b13e2

Browse files
committed
refactor(@angular/cli): Updates .gitignore to keep out VSCode and Intellij configurations.
This also changes the local build script to allow negated .gitignore expressions to support these changes.
1 parent 29a0ae3 commit 76b13e2

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

.gitignore

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,27 @@ dist/
55
dist-schema/
66

77
# IDEs
8-
.idea/
98
jsconfig.json
9+
10+
# Intellij IDEA/WebStorm
11+
# https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
12+
.idea/**/workspace.xml
13+
.idea/**/tasks.xml
14+
.idea/**/usage.statistics.xml
15+
.idea/**/dictionaries
16+
.idea/**/shelf
17+
18+
# Also ignore code styles because .editorconfig is used instead.
19+
.idea/codeStyles/
20+
21+
# VSCode
22+
# https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
1023
.vscode/
24+
!.vscode/settings.json
25+
!.vscode/tasks.json
26+
!.vscode/launch.json
27+
!.vscode/extensions.json
28+
**/*.code-workspace
1129

1230
# Typings file.
1331
typings/

scripts/build.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,23 @@ import buildSchema from './build-schema';
1717
const minimatch = require('minimatch');
1818
const tar = require('tar');
1919

20-
const gitIgnore = fs.readFileSync(path.join(__dirname, '../.gitignore'), 'utf-8')
21-
.split('\n')
20+
const gitIgnoreFiles = fs.readFileSync(path.join(__dirname, '../.gitignore'), 'utf-8')
21+
.split('\n');
22+
const gitIgnore = gitIgnoreFiles
2223
.map(line => line.replace(/#.*/, ''))
24+
.filter((line) => !line.startsWith('!'))
2325
.filter(line => !line.match(/^\s*$/));
26+
const gitIgnoreExcept = gitIgnoreFiles
27+
.filter((line) => line.startsWith('!'))
28+
.map((line) => line.substr(1));
2429

25-
26-
function _gitIgnoreMatch(p: string) {
30+
function _gitIgnoreMatch(p: string): boolean {
2731
p = path.relative(path.dirname(__dirname), p);
2832

33+
if (gitIgnoreExcept.some((line) => minimatch(p, line))) {
34+
return false;
35+
}
36+
2937
return gitIgnore.some(line => minimatch(p, line));
3038
}
3139

0 commit comments

Comments
 (0)