@@ -89,6 +89,16 @@ var _exampleProtractorBoilerplateFiles = [
89
89
'tsconfig.json'
90
90
] ;
91
91
92
+ function isDartPath ( path ) {
93
+ // Testing via indexOf() for now. If we need to match only paths with folders
94
+ // named 'dart' vs 'dart*' then try: path.match('/dart(/|$)') != null;
95
+ return path . indexOf ( '/dart' ) > - 1 ;
96
+ }
97
+
98
+ function excludeDartPaths ( paths ) {
99
+ return paths . filter ( function ( p ) { return ! isDartPath ( p ) ; } ) ;
100
+ }
101
+
92
102
/**
93
103
* Run Protractor End-to-End Specs for Doc Samples
94
104
* Alias for 'run-e2e-tests'
@@ -165,7 +175,6 @@ function runE2e() {
165
175
// with the corresponding apps that they should run under. Then run
166
176
// each app/spec collection sequentially.
167
177
function findAndRunE2eTests ( filter , outputFile ) {
168
-
169
178
// create an output file with header.
170
179
var lang = ( argv . lang || '(ts|js)' ) . toLowerCase ( ) ;
171
180
if ( lang === 'all' ) { lang = '(ts|js|dart)' ; }
@@ -203,8 +212,7 @@ function findAndRunE2eTests(filter, outputFile) {
203
212
var status = { passed : [ ] , failed : [ ] } ;
204
213
return examplePaths . reduce ( function ( promise , examplePath ) {
205
214
return promise . then ( function ( ) {
206
- var isDart = examplePath . indexOf ( '/dart' ) > - 1 ;
207
- var runTests = isDart ? runE2eDartTests : runE2eTsTests ;
215
+ var runTests = isDartPath ( examplePath ) ? runE2eDartTests : runE2eTsTests ;
208
216
return runTests ( examplePath , outputFile ) . then ( function ( ok ) {
209
217
var arr = ok ? status . passed : status . failed ;
210
218
arr . push ( examplePath ) ;
@@ -375,7 +383,7 @@ gulp.task('add-example-boilerplate', function() {
375
383
} ) ;
376
384
377
385
realPath = path . join ( EXAMPLES_PATH , '/typings' ) ;
378
- var typingsPaths = getTypingsPaths ( EXAMPLES_PATH ) ;
386
+ var typingsPaths = excludeDartPaths ( getTypingsPaths ( EXAMPLES_PATH ) ) ;
379
387
typingsPaths . forEach ( function ( linkPath ) {
380
388
gutil . log ( "symlinking " + linkPath + ' -> ' + realPath )
381
389
fsUtils . addSymlink ( realPath , linkPath ) ;
@@ -398,24 +406,26 @@ function copyExampleBoilerplate() {
398
406
var sourceFiles = _exampleBoilerplateFiles . map ( function ( fn ) {
399
407
return path . join ( EXAMPLES_PATH , fn ) ;
400
408
} ) ;
401
- var examplePaths = getExamplePaths ( EXAMPLES_PATH ) ;
409
+ var examplePaths = excludeDartPaths ( getExamplePaths ( EXAMPLES_PATH ) ) ;
402
410
403
411
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles . map ( function ( fn ) {
404
412
return path . join ( EXAMPLES_PATH , fn ) ;
405
413
} ) ;
406
414
var dartExampleWebPaths = getDartExampleWebPaths ( EXAMPLES_PATH ) ;
407
415
408
- return copyFiles ( sourceFiles , examplePaths )
416
+ // Make boilerplate files read-only to avoid that they be edited by mistake.
417
+ var destFileMode = '444' ;
418
+ return copyFiles ( sourceFiles , examplePaths , destFileMode )
409
419
. then ( function ( ) {
410
- return copyFiles ( dartWebSourceFiles , dartExampleWebPaths ) ;
420
+ return copyFiles ( dartWebSourceFiles , dartExampleWebPaths , destFileMode ) ;
411
421
} )
412
422
// copy certain files from _examples/_protractor dir to each subdir that contains an e2e-spec file.
413
423
. then ( function ( ) {
414
424
var protractorSourceFiles =
415
425
_exampleProtractorBoilerplateFiles
416
426
. map ( function ( name ) { return path . join ( EXAMPLES_PROTRACTOR_PATH , name ) ; } ) ; ;
417
427
var e2eSpecPaths = getE2eSpecPaths ( EXAMPLES_PATH ) ;
418
- return copyFiles ( protractorSourceFiles , e2eSpecPaths ) ;
428
+ return copyFiles ( protractorSourceFiles , e2eSpecPaths , destFileMode ) ;
419
429
} ) ;
420
430
}
421
431
@@ -789,16 +799,23 @@ function showHideExampleNodeModules(showOrHide) {
789
799
}
790
800
}
791
801
792
-
802
+ // Copies fileNames into destPaths, setting the mode of the
803
+ // files at the destination as optional_destFileMode if given.
793
804
// returns a promise
794
- function copyFiles ( fileNames , destPaths ) {
805
+ function copyFiles ( fileNames , destPaths , optional_destFileMode ) {
795
806
var copy = Q . denodeify ( fsExtra . copy ) ;
807
+ var chmod = Q . denodeify ( fsExtra . chmod ) ;
796
808
var copyPromises = [ ] ;
797
809
destPaths . forEach ( function ( destPath ) {
798
810
fileNames . forEach ( function ( fileName ) {
799
811
var baseName = path . basename ( fileName ) ;
800
812
var destName = path . join ( destPath , baseName ) ;
801
813
var p = copy ( fileName , destName , { clobber : true } ) ;
814
+ if ( optional_destFileMode !== undefined ) {
815
+ p = p . then ( function ( ) {
816
+ return chmod ( destName , optional_destFileMode ) ;
817
+ } ) ;
818
+ }
802
819
copyPromises . push ( p ) ;
803
820
} ) ;
804
821
} ) ;
0 commit comments