From ee3d943116c3742f89b1370b9cba7d1e9ca9aacb Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Fri, 28 Apr 2017 13:53:27 -0400 Subject: [PATCH] chore(gulp): add a new task that opens the built prod e2e test --- scripts/gulp/tasks/e2e.prod.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/gulp/tasks/e2e.prod.ts b/scripts/gulp/tasks/e2e.prod.ts index 24fcfff8b7..ca0aa5a863 100644 --- a/scripts/gulp/tasks/e2e.prod.ts +++ b/scripts/gulp/tasks/e2e.prod.ts @@ -1,3 +1,4 @@ +import { spawn } from 'child_process'; import { accessSync, readFileSync, writeFileSync } from 'fs'; import { dirname, join, relative } from 'path'; @@ -9,7 +10,7 @@ import * as runSequence from 'run-sequence'; import { argv } from 'yargs'; -import { ES_2015, PROJECT_ROOT, SRC_ROOT, SRC_COMPONENTS_ROOT, SCRIPTS_ROOT } from '../constants'; +import { DIST_E2E_COMPONENTS_ROOT, ES_2015, PROJECT_ROOT, SRC_ROOT, SRC_COMPONENTS_ROOT, SCRIPTS_ROOT } from '../constants'; import { createTempTsConfig, createTimestamp, getFolderInfo, readFileAsync, runAppScriptsBuild, writeFileAsync, writePolyfills } from '../util'; import * as pAll from 'p-all'; @@ -240,3 +241,22 @@ task('e2e.polyfill', (done: Function) => { done(err); }); }); + +task('e2e.openProd', (done: Function) => { + runSequence('e2e.prod', 'e2e.open', (err: any) => done(err)); +}); + +task('e2e.open', (done: Function) => { + const folderInfo = getFolderInfo(); + if (folderInfo && folderInfo.componentName && folderInfo.componentTest) { + const filePath = `${folderInfo.componentName}/test/${folderInfo.componentTest}/www/index.html`; + const fullPath = join(DIST_E2E_COMPONENTS_ROOT, filePath); + const spawnedCommand = spawn('open', [fullPath]); + + spawnedCommand.on('close', (code: number) => { + done(); + }); + } else { + console.log(`Can't open without folder argument.`); + } +});