Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 5adbfb9

Browse files
chalinwardbell
authored andcommitted
chore(ignored/boilerplate files): cleanup
closes #1646
1 parent b1419f4 commit 5adbfb9

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pubspec.lock
1212
.DS_Store
1313
**/*.iml
1414
.idea
15+
.vscode
1516
**/js/latest/api
1617
**/ts/latest/api
1718
**/dart/latest/api
@@ -21,8 +22,7 @@ _.*
2122
public/docs/xref-*.*
2223
_zip-output
2324
www
24-
npm-debug.log
25-
npm-debug.log.*
25+
npm-debug*.log*
2626
*.plnkr.html
2727
plnkr.html
2828
*plnkr.no-link.html

gulpfile.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ var _exampleProtractorBoilerplateFiles = [
9191

9292
var _exampleConfigFilename = 'example-config.json';
9393

94+
function isDartPath(path) {
95+
// Testing via indexOf() for now. If we need to match only paths with folders
96+
// named 'dart' vs 'dart*' then try: path.match('/dart(/|$)') != null;
97+
return path.indexOf('/dart') > -1;
98+
}
99+
100+
function excludeDartPaths(paths) {
101+
return paths.filter(function (p) { return !isDartPath(p); });
102+
}
103+
94104
/**
95105
* Run Protractor End-to-End Specs for Doc Samples
96106
* Alias for 'run-e2e-tests'
@@ -167,7 +177,6 @@ function runE2e() {
167177
// with the corresponding apps that they should run under. Then run
168178
// each app/spec collection sequentially.
169179
function findAndRunE2eTests(filter, outputFile) {
170-
171180
// create an output file with header.
172181
var lang = (argv.lang || '(ts|js)').toLowerCase();
173182
if (lang === 'all') { lang = '(ts|js|dart)'; }
@@ -205,8 +214,7 @@ function findAndRunE2eTests(filter, outputFile) {
205214
var status = { passed: [], failed: [] };
206215
return examplePaths.reduce(function (promise, examplePath) {
207216
return promise.then(function () {
208-
var isDart = examplePath.indexOf('/dart') > -1;
209-
var runTests = isDart ? runE2eDartTests : runE2eTsTests;
217+
var runTests = isDartPath(examplePath) ? runE2eDartTests : runE2eTsTests;
210218
return runTests(examplePath, outputFile).then(function(ok) {
211219
var arr = ok ? status.passed : status.failed;
212220
arr.push(examplePath);
@@ -378,7 +386,7 @@ gulp.task('add-example-boilerplate', function() {
378386
});
379387

380388
realPath = path.join(EXAMPLES_PATH, '/typings');
381-
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
389+
var typingsPaths = excludeDartPaths(getTypingsPaths(EXAMPLES_PATH));
382390
typingsPaths.forEach(function(linkPath) {
383391
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
384392
fsUtils.addSymlink(realPath, linkPath);
@@ -401,24 +409,26 @@ function copyExampleBoilerplate() {
401409
var sourceFiles = _exampleBoilerplateFiles.map(function(fn) {
402410
return path.join(EXAMPLES_PATH, fn);
403411
});
404-
var examplePaths = getExamplePaths(EXAMPLES_PATH);
412+
var examplePaths = excludeDartPaths(getExamplePaths(EXAMPLES_PATH));
405413

406414
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles.map(function(fn){
407415
return path.join(EXAMPLES_PATH, fn);
408416
});
409417
var dartExampleWebPaths = getDartExampleWebPaths(EXAMPLES_PATH);
410418

411-
return copyFiles(sourceFiles, examplePaths)
419+
// Make boilerplate files read-only to avoid that they be edited by mistake.
420+
var destFileMode = '444';
421+
return copyFiles(sourceFiles, examplePaths, destFileMode)
412422
.then(function() {
413-
return copyFiles(dartWebSourceFiles, dartExampleWebPaths);
423+
return copyFiles(dartWebSourceFiles, dartExampleWebPaths, destFileMode);
414424
})
415425
// copy certain files from _examples/_protractor dir to each subdir that contains an e2e-spec file.
416426
.then(function() {
417427
var protractorSourceFiles =
418428
_exampleProtractorBoilerplateFiles
419429
.map(function(name) {return path.join(EXAMPLES_PROTRACTOR_PATH, name);});;
420430
var e2eSpecPaths = getE2eSpecPaths(EXAMPLES_PATH);
421-
return copyFiles(protractorSourceFiles, e2eSpecPaths);
431+
return copyFiles(protractorSourceFiles, e2eSpecPaths, destFileMode);
422432
});
423433
}
424434

@@ -792,16 +802,23 @@ function showHideExampleNodeModules(showOrHide) {
792802
}
793803
}
794804

795-
805+
// Copies fileNames into destPaths, setting the mode of the
806+
// files at the destination as optional_destFileMode if given.
796807
// returns a promise
797-
function copyFiles(fileNames, destPaths) {
808+
function copyFiles(fileNames, destPaths, optional_destFileMode) {
798809
var copy = Q.denodeify(fsExtra.copy);
810+
var chmod = Q.denodeify(fsExtra.chmod);
799811
var copyPromises = [];
800812
destPaths.forEach(function(destPath) {
801813
fileNames.forEach(function(fileName) {
802814
var baseName = path.basename(fileName);
803815
var destName = path.join(destPath, baseName);
804816
var p = copy(fileName, destName, { clobber: true});
817+
if(optional_destFileMode !== undefined) {
818+
p = p.then(function () {
819+
return chmod(destName, optional_destFileMode);
820+
});
821+
}
805822
copyPromises.push(p);
806823
});
807824
});

public/docs/_examples/.gitignore

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1+
# _exampleBoilerplateFiles
12
.editorconfig
2-
.idea
3-
.vscode
4-
styles.css
5-
typings
6-
typings.json
7-
node_modules
8-
jspm_packages
9-
*.js.map
10-
package.json
113
karma.conf.js
124
karma-test-shim.js
5+
package.json
6+
*/**/styles.css
7+
systemjs.config.js
138
tsconfig.json
149
tslint.json
10+
typings.json
1511
wallaby.js
16-
npm-debug*.
12+
1713
protractor.config.js
18-
systemjs.config.js
1914
_test-output
20-
_temp
2115
**/ts/**/*.js
2216
**/ts-snippets/**/*.js
2317
*.d.ts

0 commit comments

Comments
 (0)