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.
This commit is contained in:
Doug Parker 2019-11-12 11:17:18 -08:00 committed by Douglas Parker
parent 29a0ae3b1d
commit 76b13e2dea
2 changed files with 31 additions and 5 deletions

20
.gitignore vendored
View File

@ -5,9 +5,27 @@ dist/
dist-schema/
# IDEs
.idea/
jsconfig.json
# Intellij IDEA/WebStorm
# https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Also ignore code styles because .editorconfig is used instead.
.idea/codeStyles/
# VSCode
# https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
.vscode/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
**/*.code-workspace
# Typings file.
typings/

View File

@ -17,15 +17,23 @@ import buildSchema from './build-schema';
const minimatch = require('minimatch');
const tar = require('tar');
const gitIgnore = fs.readFileSync(path.join(__dirname, '../.gitignore'), 'utf-8')
.split('\n')
const gitIgnoreFiles = fs.readFileSync(path.join(__dirname, '../.gitignore'), 'utf-8')
.split('\n');
const gitIgnore = gitIgnoreFiles
.map(line => line.replace(/#.*/, ''))
.filter((line) => !line.startsWith('!'))
.filter(line => !line.match(/^\s*$/));
const gitIgnoreExcept = gitIgnoreFiles
.filter((line) => line.startsWith('!'))
.map((line) => line.substr(1));
function _gitIgnoreMatch(p: string) {
function _gitIgnoreMatch(p: string): boolean {
p = path.relative(path.dirname(__dirname), p);
if (gitIgnoreExcept.some((line) => minimatch(p, line))) {
return false;
}
return gitIgnore.some(line => minimatch(p, line));
}