@@ -91,6 +91,16 @@ var _exampleProtractorBoilerplateFiles = [
91
91
92
92
var _exampleConfigFilename = 'example-config.json' ;
93
93
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
+
94
104
/**
95
105
* Run Protractor End-to-End Specs for Doc Samples
96
106
* Alias for 'run-e2e-tests'
@@ -167,7 +177,6 @@ function runE2e() {
167
177
// with the corresponding apps that they should run under. Then run
168
178
// each app/spec collection sequentially.
169
179
function findAndRunE2eTests ( filter , outputFile ) {
170
-
171
180
// create an output file with header.
172
181
var lang = ( argv . lang || '(ts|js)' ) . toLowerCase ( ) ;
173
182
if ( lang === 'all' ) { lang = '(ts|js|dart)' ; }
@@ -205,8 +214,7 @@ function findAndRunE2eTests(filter, outputFile) {
205
214
var status = { passed : [ ] , failed : [ ] } ;
206
215
return examplePaths . reduce ( function ( promise , examplePath ) {
207
216
return promise . then ( function ( ) {
208
- var isDart = examplePath . indexOf ( '/dart' ) > - 1 ;
209
- var runTests = isDart ? runE2eDartTests : runE2eTsTests ;
217
+ var runTests = isDartPath ( examplePath ) ? runE2eDartTests : runE2eTsTests ;
210
218
return runTests ( examplePath , outputFile ) . then ( function ( ok ) {
211
219
var arr = ok ? status . passed : status . failed ;
212
220
arr . push ( examplePath ) ;
@@ -378,7 +386,7 @@ gulp.task('add-example-boilerplate', function() {
378
386
} ) ;
379
387
380
388
realPath = path . join ( EXAMPLES_PATH , '/typings' ) ;
381
- var typingsPaths = getTypingsPaths ( EXAMPLES_PATH ) ;
389
+ var typingsPaths = excludeDartPaths ( getTypingsPaths ( EXAMPLES_PATH ) ) ;
382
390
typingsPaths . forEach ( function ( linkPath ) {
383
391
gutil . log ( "symlinking " + linkPath + ' -> ' + realPath )
384
392
fsUtils . addSymlink ( realPath , linkPath ) ;
@@ -401,24 +409,26 @@ function copyExampleBoilerplate() {
401
409
var sourceFiles = _exampleBoilerplateFiles . map ( function ( fn ) {
402
410
return path . join ( EXAMPLES_PATH , fn ) ;
403
411
} ) ;
404
- var examplePaths = getExamplePaths ( EXAMPLES_PATH ) ;
412
+ var examplePaths = excludeDartPaths ( getExamplePaths ( EXAMPLES_PATH ) ) ;
405
413
406
414
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles . map ( function ( fn ) {
407
415
return path . join ( EXAMPLES_PATH , fn ) ;
408
416
} ) ;
409
417
var dartExampleWebPaths = getDartExampleWebPaths ( EXAMPLES_PATH ) ;
410
418
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 )
412
422
. then ( function ( ) {
413
- return copyFiles ( dartWebSourceFiles , dartExampleWebPaths ) ;
423
+ return copyFiles ( dartWebSourceFiles , dartExampleWebPaths , destFileMode ) ;
414
424
} )
415
425
// copy certain files from _examples/_protractor dir to each subdir that contains an e2e-spec file.
416
426
. then ( function ( ) {
417
427
var protractorSourceFiles =
418
428
_exampleProtractorBoilerplateFiles
419
429
. map ( function ( name ) { return path . join ( EXAMPLES_PROTRACTOR_PATH , name ) ; } ) ; ;
420
430
var e2eSpecPaths = getE2eSpecPaths ( EXAMPLES_PATH ) ;
421
- return copyFiles ( protractorSourceFiles , e2eSpecPaths ) ;
431
+ return copyFiles ( protractorSourceFiles , e2eSpecPaths , destFileMode ) ;
422
432
} ) ;
423
433
}
424
434
@@ -792,16 +802,23 @@ function showHideExampleNodeModules(showOrHide) {
792
802
}
793
803
}
794
804
795
-
805
+ // Copies fileNames into destPaths, setting the mode of the
806
+ // files at the destination as optional_destFileMode if given.
796
807
// returns a promise
797
- function copyFiles ( fileNames , destPaths ) {
808
+ function copyFiles ( fileNames , destPaths , optional_destFileMode ) {
798
809
var copy = Q . denodeify ( fsExtra . copy ) ;
810
+ var chmod = Q . denodeify ( fsExtra . chmod ) ;
799
811
var copyPromises = [ ] ;
800
812
destPaths . forEach ( function ( destPath ) {
801
813
fileNames . forEach ( function ( fileName ) {
802
814
var baseName = path . basename ( fileName ) ;
803
815
var destName = path . join ( destPath , baseName ) ;
804
816
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
+ }
805
822
copyPromises . push ( p ) ;
806
823
} ) ;
807
824
} ) ;
0 commit comments