From f463e09b9f864f6d796a062e1a4935fa49be36bf Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 23 Jun 2016 14:26:54 -0700 Subject: [PATCH] fix(ngc): work with typescript@next This is required due to breaking change in TS, see https://github.com/Microsoft/TypeScript/pull/8841#issuecomment-227300348 --- scripts/ci-lite/offline_compiler_test.sh | 5 +++++ tools/@angular/tsc-wrapped/src/tsc.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/ci-lite/offline_compiler_test.sh b/scripts/ci-lite/offline_compiler_test.sh index 47fbfea408..9d13b06f86 100755 --- a/scripts/ci-lite/offline_compiler_test.sh +++ b/scripts/ci-lite/offline_compiler_test.sh @@ -31,6 +31,7 @@ cp -v package.json $TMP # TODO(alexeagle): allow this to be npm link instead npm install ${LINKABLE_PKGS[*]} + ./node_modules/.bin/tsc --version # Compile the compiler-cli integration tests ./node_modules/.bin/ngc ./node_modules/.bin/ng-xi18n @@ -38,4 +39,8 @@ cp -v package.json $TMP ./node_modules/.bin/jasmine init # Run compiler-cli integration tests in node ./node_modules/.bin/jasmine test/*_spec.js + + # Compile again with a differently named tsconfig file + mv tsconfig.json othername.json + ./node_modules/.bin/ngc -p othername.json ) diff --git a/tools/@angular/tsc-wrapped/src/tsc.ts b/tools/@angular/tsc-wrapped/src/tsc.ts index f3150e5593..57ff82c0bc 100644 --- a/tools/@angular/tsc-wrapped/src/tsc.ts +++ b/tools/@angular/tsc-wrapped/src/tsc.ts @@ -54,9 +54,11 @@ export class Tsc implements CompilerInterface { this.basePath = basePath; // Allow a directory containing tsconfig.json as the project value + // Note, TS@next returns an empty array, while earlier versions throw try { - this.readDirectory(project); - project = path.join(project, 'tsconfig.json'); + if (this.readDirectory(project).length > 0) { + project = path.join(project, 'tsconfig.json'); + } } catch (e) { // Was not a directory, continue on assuming it's a file }