@@ -91,6 +91,16 @@ var _exampleProtractorBoilerplateFiles = [
9191
9292var _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.
169179function 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 } ) ;
0 commit comments