diff --git a/src/util/config.spec.ts b/src/util/config.spec.ts index d6ee6f1e..94e394d1 100644 --- a/src/util/config.spec.ts +++ b/src/util/config.spec.ts @@ -101,6 +101,7 @@ describe('config', () => { expect(fakeConfig[Constants.ENV_BAIL_ON_LINT_ERROR]).toBeFalsy(); expect(fakeConfig[Constants.ENV_ENABLE_LINT]).toEqual('true'); expect(fakeConfig[Constants.ENV_DISABLE_LOGGING]).toBeFalsy(); + expect(fakeConfig[Constants.ENV_START_WATCH_TIMEOUT]).toEqual('3000'); expect(fakeConfig[Constants.ENV_ACTION_SHEET_CONTROLLER_CLASSNAME]).toEqual('ActionSheetController'); expect(fakeConfig[Constants.ENV_ACTION_SHEET_CONTROLLER_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-controller.js')); diff --git a/src/util/config.ts b/src/util/config.ts index e38d2cff..9bbbb5b8 100644 --- a/src/util/config.ts +++ b/src/util/config.ts @@ -197,6 +197,10 @@ export function generateContext(context?: BuildContext): BuildContext { setProcessEnvVar(Constants.ENV_DISABLE_LOGGING, disableLogging); Logger.debug(`disableLogging set to ${disableLogging}`); + const startWatchTimeout = getConfigValue(context, '--startWatchTimeout', null, Constants.ENV_START_WATCH_TIMEOUT, Constants.ENV_START_WATCH_TIMEOUT.toLowerCase(), '3000'); + setProcessEnvVar(Constants.ENV_START_WATCH_TIMEOUT, startWatchTimeout); + Logger.debug(`startWatchTimeout set to ${startWatchTimeout}`); + /* Provider Path Stuff */ setProcessEnvVar(Constants.ENV_ACTION_SHEET_CONTROLLER_CLASSNAME, 'ActionSheetController'); setProcessEnvVar(Constants.ENV_ACTION_SHEET_CONTROLLER_PATH, join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-controller.js')); diff --git a/src/util/constants.ts b/src/util/constants.ts index 83fa9822..7d1edd39 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -39,7 +39,6 @@ export const ENV_GLOB_UTIL = 'IONIC_GLOB_UTIL'; export const ENV_CLEAN_BEFORE_COPY = 'IONIC_CLEAN_BEFORE_COPY'; export const ENV_CLOSURE_JAR = 'IONIC_CLOSURE_JAR'; export const ENV_READ_CONFIG_JSON = 'IONIC_READ_CONFIG_JSON'; - export const ENV_OUTPUT_JS_FILE_NAME = 'IONIC_OUTPUT_JS_FILE_NAME'; export const ENV_OUTPUT_CSS_FILE_NAME = 'IONIC_OUTPUT_CSS_FILE_NAME'; export const ENV_WEBPACK_FACTORY = 'IONIC_WEBPACK_FACTORY'; @@ -50,6 +49,7 @@ export const ENV_BAIL_ON_LINT_ERROR = 'IONIC_BAIL_ON_LINT_ERROR'; export const ENV_BUILD_TO_ES5 = 'IONIC_BUILD_TO_ES5'; export const ENV_ENABLE_LINT = 'IONIC_ENABLE_LINT'; export const ENV_DISABLE_LOGGING = 'IONIC_DISABLE_LOGGING'; +export const ENV_START_WATCH_TIMEOUT = 'IONIC_START_WATCH_TIMEOUT'; export const ENV_PRINT_ORIGINAL_DEPENDENCY_TREE = 'IONIC_PRINT_ORIGINAL_DEPENDENCY_TREE'; export const ENV_PRINT_MODIFIED_DEPENDENCY_TREE = 'IONIC_PRINT_MODIFIED_DEPENDENCY_TREE'; diff --git a/src/util/helpers.ts b/src/util/helpers.ts index 399059c4..d7050d29 100644 --- a/src/util/helpers.ts +++ b/src/util/helpers.ts @@ -265,6 +265,11 @@ export function generateRandomHexString(numCharacters: number) { return randomBytes(Math.ceil(numCharacters / 2)).toString('hex').slice(0, numCharacters); } +export function getIntPropertyValue(propertyName: string) { + const result = process.env[propertyName]; + return parseInt(result, 0); +} + export function getBooleanPropertyValue(propertyName: string) { const result = process.env[propertyName]; return result === 'true'; diff --git a/src/watch.ts b/src/watch.ts index d3a8000e..541d1ee0 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -1,12 +1,16 @@ +import { extname, join, normalize, resolve as pathResolve } from 'path'; + +import * as chokidar from 'chokidar'; + import * as buildTask from './build'; import { copyUpdate as copyUpdateHandler} from './copy'; -import { BuildContext, BuildState, ChangedFile, TaskInfo } from './util/interfaces'; -import { BuildError } from './util/errors'; +import { Logger } from './logger/logger'; import { canRunTranspileUpdate } from './transpile'; import { fillConfigDefaults, getUserConfigFile, replacePathVars } from './util/config'; -import { extname, join, normalize, resolve as pathResolve } from 'path'; -import { Logger } from './logger/logger'; -import * as chokidar from 'chokidar'; +import * as Constants from './util/constants'; +import { BuildError } from './util/errors'; +import { getIntPropertyValue } from './util/helpers'; +import { BuildContext, BuildState, ChangedFile, TaskInfo } from './util/interfaces'; // https://github.com/paulmillr/chokidar @@ -77,7 +81,7 @@ function startWatcher(name: string, watcher: Watcher, context: BuildContext) { filesWatchedString = watcher.paths.join(', '); } reject(new BuildError(`A watch configured to watch the following paths failed to start. It likely that a file referenced does not exist: ${filesWatchedString}`)); - }, 3000); + }, getIntPropertyValue(Constants.ENV_START_WATCH_TIMEOUT)); prepareWatcher(context, watcher); if (!watcher.paths) {