@@ -89,7 +89,8 @@ var _exampleBoilerplateFiles = [
8989 'styles.css' ,
9090 'systemjs.config.js' ,
9191 'tsconfig.json' ,
92- 'tslint.json'
92+ 'tslint.json' ,
93+ 'angular-cli.json'
9394] ;
9495
9596var _exampleDartWebBoilerPlateFiles = [ 'a2docs.css' , 'styles.css' ] ;
@@ -154,6 +155,24 @@ function excludeDartPaths(paths) {
154155 return paths . filter ( function ( p ) { return ! isDartPath ( p ) ; } ) ;
155156}
156157
158+ // Load example config and set defaults
159+ function getExampleConfig ( appDir ) {
160+ var exampleConfig = { } ;
161+ try {
162+ exampleConfig = fs . readJsonSync ( `${ appDir } /${ _exampleConfigFilename } ` ) ;
163+ } catch ( e ) { }
164+
165+ exampleConfig . build = exampleConfig . build || 'tsc' ;
166+ exampleConfig . run = exampleConfig . run || 'http-server:e2e' ;
167+
168+ // Override config if the cli flag is set for tests
169+ if ( argv . cli ) {
170+ exampleConfig . build = 'build:cli' ;
171+ exampleConfig . run = 'http-server:cli' ;
172+ }
173+ return exampleConfig ;
174+ }
175+
157176/**
158177 * Run Protractor End-to-End Specs for Doc Samples
159178 * Alias for 'run-e2e-tests'
@@ -249,11 +268,32 @@ function findAndRunE2eTests(filter, outputFile) {
249268 localExamplePaths = localExamplePaths . filter ( function ( fn ) {
250269 return fn . match ( '/' + lang + '(?:-[^/]*)?$' ) != null ;
251270 } ) ;
271+
252272 localExamplePaths . forEach ( function ( examplePath ) {
253273 examplePaths . push ( examplePath ) ;
254274 } )
255275 } ) ;
256276
277+ // Filter suites that
278+ if ( argv . cli ) {
279+ var cliSuitesSkipped = [ ] ;
280+ examplePaths = examplePaths . filter ( function ( appDir ) {
281+ var config = getExampleConfig ( appDir ) ;
282+ if ( config . skipCli ) { cliSuitesSkipped . push ( appDir ) ; }
283+ return ! config . skipCli ;
284+ } ) ;
285+ if ( cliSuitesSkipped . length > 0 ) {
286+ var log = [ '' ] ;
287+ log . push ( `Suites skipped due to "skipCli" in ${ _exampleConfigFilename } :` ) ;
288+ cliSuitesSkipped . forEach ( function ( val ) {
289+ log . push ( ' ' + val ) ;
290+ } ) ;
291+ log = log . join ( '\n' ) ;
292+ gutil . log ( log ) ;
293+ fs . appendFileSync ( outputFile , log ) ;
294+ }
295+ }
296+
257297 // run the tests sequentially
258298 var status = { passed : [ ] , failed : [ ] } ;
259299 return examplePaths . reduce ( function ( promise , examplePath ) {
@@ -275,24 +315,13 @@ function findAndRunE2eTests(filter, outputFile) {
275315// fileName; then shut down the example. All protractor output is appended
276316// to the outputFile.
277317function runE2eTsTests ( appDir , outputFile ) {
278- // Grab protractor configuration or defaults to systemjs config.
279- try {
280- var exampleConfig = fs . readJsonSync ( `${ appDir } /${ _exampleConfigFilename } ` ) ;
281- } catch ( e ) {
282- exampleConfig = { } ;
283- }
284-
285- var config = {
286- build : exampleConfig . build || 'tsc' ,
287- run : exampleConfig . run || 'http-server:e2e'
288- } ;
289-
318+ var config = getExampleConfig ( appDir ) ;
290319 var appBuildSpawnInfo = spawnExt ( 'npm' , [ 'run' , config . build ] , { cwd : appDir } ) ;
291320 var appRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , config . run , '--' , '-s' ] , { cwd : appDir } ) ;
292321
293322 var run = runProtractor ( appBuildSpawnInfo . promise , appDir , appRunSpawnInfo , outputFile ) ;
294323
295- if ( fs . existsSync ( appDir + '/aot/index.html' ) ) {
324+ if ( fs . existsSync ( appDir + '/aot/index.html' ) && ! argv . cli ) {
296325 run = run . then ( ( ) => runProtractorAoT ( appDir , outputFile ) ) ;
297326 }
298327 return run ;
0 commit comments