@@ -398,24 +398,28 @@ function copyExampleBoilerplate() {
398
398
var sourceFiles = _exampleBoilerplateFiles . map ( function ( fn ) {
399
399
return path . join ( EXAMPLES_PATH , fn ) ;
400
400
} ) ;
401
- var examplePaths = getExamplePaths ( EXAMPLES_PATH ) ;
401
+ var _examplePaths = getExamplePaths ( EXAMPLES_PATH ) ;
402
+ // Exclude Dart paths since they are processed separately.
403
+ var examplePaths = _examplePaths . filter ( function ( p ) { return p . match ( '/dart(/|$)' ) == null ; } ) ;
402
404
403
405
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles . map ( function ( fn ) {
404
406
return path . join ( EXAMPLES_PATH , fn ) ;
405
407
} ) ;
406
408
var dartExampleWebPaths = getDartExampleWebPaths ( EXAMPLES_PATH ) ;
407
409
408
- return copyFiles ( sourceFiles , examplePaths )
410
+ // Make boilerplate files read-only to avoid that they be edited by mistake.
411
+ var destFileMode = '444' ;
412
+ return copyFiles ( sourceFiles , examplePaths , destFileMode )
409
413
. then ( function ( ) {
410
- return copyFiles ( dartWebSourceFiles , dartExampleWebPaths ) ;
414
+ return copyFiles ( dartWebSourceFiles , dartExampleWebPaths , destFileMode ) ;
411
415
} )
412
416
// copy certain files from _examples/_protractor dir to each subdir that contains an e2e-spec file.
413
417
. then ( function ( ) {
414
418
var protractorSourceFiles =
415
419
_exampleProtractorBoilerplateFiles
416
420
. map ( function ( name ) { return path . join ( EXAMPLES_PROTRACTOR_PATH , name ) ; } ) ; ;
417
421
var e2eSpecPaths = getE2eSpecPaths ( EXAMPLES_PATH ) ;
418
- return copyFiles ( protractorSourceFiles , e2eSpecPaths ) ;
422
+ return copyFiles ( protractorSourceFiles , e2eSpecPaths , destFileMode ) ;
419
423
} ) ;
420
424
}
421
425
@@ -789,16 +793,23 @@ function showHideExampleNodeModules(showOrHide) {
789
793
}
790
794
}
791
795
792
-
796
+ // Copies fileNames into destPaths, setting the mode of the
797
+ // files at the destination as optional_destFileMode if given.
793
798
// returns a promise
794
- function copyFiles ( fileNames , destPaths ) {
799
+ function copyFiles ( fileNames , destPaths , optional_destFileMode ) {
795
800
var copy = Q . denodeify ( fsExtra . copy ) ;
801
+ var chmod = Q . denodeify ( fsExtra . chmod ) ;
796
802
var copyPromises = [ ] ;
797
803
destPaths . forEach ( function ( destPath ) {
798
804
fileNames . forEach ( function ( fileName ) {
799
805
var baseName = path . basename ( fileName ) ;
800
806
var destName = path . join ( destPath , baseName ) ;
801
807
var p = copy ( fileName , destName , { clobber : true } ) ;
808
+ if ( optional_destFileMode !== undefined ) {
809
+ p = p . then ( function ( ) {
810
+ return chmod ( destName , optional_destFileMode ) ;
811
+ } ) ;
812
+ }
802
813
copyPromises . push ( p ) ;
803
814
} ) ;
804
815
} ) ;
0 commit comments