build(aio): ignore example files that are gitignored

Rather than hard coding excludes into the dgeni config,
use the fact that we are already ignoring the boilerplate
and generated files via the .gitignore file.
This commit is contained in:
Peter Bacon Darwin
2017-06-07 22:34:11 +01:00
committed by Pete Bacon Darwin
parent e894f5c399
commit 3db6b6ca7a
4 changed files with 22 additions and 23 deletions

View File

@ -6,17 +6,29 @@
* found in the LICENSE file at https://angular.io/license
*/
const Package = require('dgeni').Package;
const globby = require('globby');
const ignore = require('ignore');
const fs = require('fs');
const path = require('canonical-path');
const basePackage = require('../angular-base-package');
const contentPackage = require('../content-package');
const { CONTENTS_PATH } = require('../config');
const { CONTENTS_PATH, GUIDE_EXAMPLES_PATH } = require('../config');
module.exports = new Package('angular-content', [basePackage, contentPackage])
// Where do we get the source files?
.config(function(readFilesProcessor, collectExamples) {
const gitignoreFile = fs.readFileSync(path.resolve(GUIDE_EXAMPLES_PATH, '.gitignore'), 'utf8');
const gitignore = ignore().add(gitignoreFile);
const examplePaths = globby.sync('**/*', { cwd: GUIDE_EXAMPLES_PATH, mark: true, dot: true })
.filter(filePath => filePath !== '.gitignore') // we are not interested in the .gitignore file itself
.filter(filePath => !/\/$/.test(filePath)); // this filter removes the folders, leaving only files
const filteredExamplePaths = gitignore.filter(examplePaths) // filter out files that match the .gitignore rules
.map(filePath => path.resolve(GUIDE_EXAMPLES_PATH, filePath)); // we need the full paths for the filereader
readFilesProcessor.sourceFiles = readFilesProcessor.sourceFiles.concat([
{
basePath: CONTENTS_PATH,
@ -36,26 +48,7 @@ module.exports = new Package('angular-content', [basePackage, contentPackage])
},
{
basePath: CONTENTS_PATH,
include: CONTENTS_PATH + '/examples/**/*',
exclude: [
'**/*plnkr.no-link.html',
'**/node_modules/**',
// boilerplate files
'**/*/src/systemjs-angular-loader.js',
'**/*/src/systemjs.config.js',
'**/*/src/tsconfig.json',
'**/*/bs-config.e2e.json',
'**/*/bs-config.json',
'**/*/package.json',
'**/*/tslint.json',
// example files
'**/_test-output',
'**/protractor-helpers.js',
'**/e2e-spec.js',
'**/ts/**/*.js',
'**/js-es6*/**/*.js',
'**/ts-snippets/**/*.js',
],
include: filteredExamplePaths,
fileReader: 'exampleFileReader'
},
{