From 0297398f5e04379823715a033320bd5fb852db02 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Tue, 3 May 2016 18:49:59 -0700 Subject: [PATCH] chore: clang-format master --- modules/@angular/compiler/src/template_ast.ts | 7 +- .../src/view_compiler/property_binder.ts | 3 +- .../src/view_compiler/view_builder.ts | 4 +- .../dom_element_schema_registry_spec.ts | 5 +- modules/@angular/compiler_cli/src/codegen.ts | 21 +++-- .../compiler_cli/src/compiler_private.ts | 3 +- modules/@angular/compiler_cli/src/main.ts | 2 +- .../compiler_cli/src/static_reflector.ts | 6 +- .../test/static_reflector_spec.ts | 6 +- .../@angular/core/src/linker/view_utils.ts | 5 +- .../test/linker/security_integration_spec.ts | 6 +- .../router/src/directives/router_link.ts | 2 +- modules/@angular/router/src/link.ts | 49 +++++++----- modules/@angular/router/src/recognize.ts | 3 +- modules/@angular/router/src/segments.ts | 4 +- modules/@angular/router/test/link_spec.ts | 4 +- .../@angular/router/test/router_link_spec.ts | 26 +++--- tools/cjs-jasmine/index-tools.ts | 13 +-- tools/tsc-watch/index.ts | 79 ++++++++++--------- 19 files changed, 130 insertions(+), 118 deletions(-) diff --git a/modules/@angular/compiler/src/template_ast.ts b/modules/@angular/compiler/src/template_ast.ts index 0ea10bd321..8d0e149c2d 100644 --- a/modules/@angular/compiler/src/template_ast.ts +++ b/modules/@angular/compiler/src/template_ast.ts @@ -55,10 +55,9 @@ export class AttrAst implements TemplateAst { * A binding for an element property (e.g. `[property]="expression"`). */ export class BoundElementPropertyAst implements TemplateAst { - constructor( - public name: string, public type: PropertyBindingType, - public securityContext: SecurityContext, public value: AST, public unit: string, - public sourceSpan: ParseSourceSpan) {} + constructor(public name: string, public type: PropertyBindingType, + public securityContext: SecurityContext, public value: AST, public unit: string, + public sourceSpan: ParseSourceSpan) {} visit(visitor: TemplateAstVisitor, context: any): any { return visitor.visitElementProperty(this, context); } diff --git a/modules/@angular/compiler/src/view_compiler/property_binder.ts b/modules/@angular/compiler/src/view_compiler/property_binder.ts index 9d08460f16..f23c6b79fd 100644 --- a/modules/@angular/compiler/src/view_compiler/property_binder.ts +++ b/modules/@angular/compiler/src/view_compiler/property_binder.ts @@ -131,7 +131,8 @@ function bindAndWriteToRenderer(boundProps: BoundElementPropertyAst[], context: }); } -function sanitizedValue(boundProp: BoundElementPropertyAst, renderValue: o.Expression): o.Expression { +function sanitizedValue(boundProp: BoundElementPropertyAst, + renderValue: o.Expression): o.Expression { let enumValue: string; switch (boundProp.securityContext) { case SecurityContext.NONE: diff --git a/modules/@angular/compiler/src/view_compiler/view_builder.ts b/modules/@angular/compiler/src/view_compiler/view_builder.ts index 2eaea85daf..7f5f30cf01 100644 --- a/modules/@angular/compiler/src/view_compiler/view_builder.ts +++ b/modules/@angular/compiler/src/view_compiler/view_builder.ts @@ -214,7 +214,7 @@ class ViewBuilderVisitor implements TemplateAstVisitor { var nestedComponentIdentifier = new CompileIdentifierMetadata({name: getViewFactoryName(component, 0)}); this.targetDependencies.push(new ViewCompileDependency(component, nestedComponentIdentifier)); - compViewExpr = o.variable(`compView_${nodeIndex}`); // fix highlighting: ` + compViewExpr = o.variable(`compView_${nodeIndex}`); // fix highlighting: ` compileElement.setComponentView(compViewExpr); this.view.createMethod.addStmt(compViewExpr.set(o.importExpr(nestedComponentIdentifier) .callFn([ @@ -337,7 +337,7 @@ function createViewTopLevelStmts(view: CompileView, targetStatements: o.Statemen var nodeDebugInfosVar: o.Expression = o.NULL_EXPR; if (view.genConfig.genDebugInfo) { nodeDebugInfosVar = o.variable( - `nodeDebugInfos_${view.component.type.name}${view.viewIndex}`); // fix highlighting: ` + `nodeDebugInfos_${view.component.type.name}${view.viewIndex}`); // fix highlighting: ` targetStatements.push( (nodeDebugInfosVar) .set(o.literalArr(view.nodes.map(createStaticNodeDebugInfo), diff --git a/modules/@angular/compiler/test/schema/dom_element_schema_registry_spec.ts b/modules/@angular/compiler/test/schema/dom_element_schema_registry_spec.ts index 9acbdb94b8..d5f1cd9367 100644 --- a/modules/@angular/compiler/test/schema/dom_element_schema_registry_spec.ts +++ b/modules/@angular/compiler/test/schema/dom_element_schema_registry_spec.ts @@ -57,9 +57,8 @@ export function main() { expect(registry.getMappedPropName('exotic-unknown')).toEqual('exotic-unknown'); }); - it('should return security contexts for elements', () => { - expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL); - }); + it('should return security contexts for elements', + () => { expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL); }); it('should detect properties on namespaced elements', () => { expect(registry.hasProperty('@svg:g', 'id')).toBeTruthy(); }); diff --git a/modules/@angular/compiler_cli/src/codegen.ts b/modules/@angular/compiler_cli/src/codegen.ts index 954bc57a2d..f1f9066e6c 100644 --- a/modules/@angular/compiler_cli/src/codegen.ts +++ b/modules/@angular/compiler_cli/src/codegen.ts @@ -8,9 +8,17 @@ import * as path from 'path'; import * as compiler from '@angular/compiler'; import {ViewEncapsulation} from '@angular/core'; import {StaticReflector} from './static_reflector'; -import {CompileMetadataResolver, HtmlParser, DirectiveNormalizer, Lexer, Parser, -TemplateParser, DomElementSchemaRegistry, StyleCompiler, -ViewCompiler, TypeScriptEmitter +import { + CompileMetadataResolver, + HtmlParser, + DirectiveNormalizer, + Lexer, + Parser, + TemplateParser, + DomElementSchemaRegistry, + StyleCompiler, + ViewCompiler, + TypeScriptEmitter } from './compiler_private'; import {Parse5DomAdapter} from '@angular/platform-server'; @@ -96,8 +104,7 @@ export class CodeGenerator { let root = this.ngOptions.basePath; for (let eachRootDir of this.options.rootDirs || []) { if (this.ngOptions.trace) { - console.log( - `Check if ${filePath} is under rootDirs element ${eachRootDir}`); + console.log(`Check if ${filePath} is under rootDirs element ${eachRootDir}`); } if (path.relative(eachRootDir, filePath).indexOf('.') !== 0) { root = eachRootDir; @@ -170,7 +177,7 @@ export class CodeGenerator { new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector), new compiler.ViewResolver(staticReflector), null, null, staticReflector); - return new CodeGenerator(options, ngOptions, program, compilerHost, - staticReflector, resolver, offlineCompiler, reflectorHost); + return new CodeGenerator(options, ngOptions, program, compilerHost, staticReflector, resolver, + offlineCompiler, reflectorHost); } } diff --git a/modules/@angular/compiler_cli/src/compiler_private.ts b/modules/@angular/compiler_cli/src/compiler_private.ts index 65429dc8a4..7cea60bb00 100644 --- a/modules/@angular/compiler_cli/src/compiler_private.ts +++ b/modules/@angular/compiler_cli/src/compiler_private.ts @@ -25,7 +25,8 @@ export type TemplateParser = _c.TemplateParser; export var TemplateParser: typeof _c.TemplateParser = _c.TemplateParser; export type DomElementSchemaRegistry = _c.DomElementSchemaRegistry; -export var DomElementSchemaRegistry: typeof _c.DomElementSchemaRegistry = _c.DomElementSchemaRegistry; +export var DomElementSchemaRegistry: typeof _c.DomElementSchemaRegistry = + _c.DomElementSchemaRegistry; export type StyleCompiler = _c.StyleCompiler; export var StyleCompiler: typeof _c.StyleCompiler = _c.StyleCompiler; diff --git a/modules/@angular/compiler_cli/src/main.ts b/modules/@angular/compiler_cli/src/main.ts index cc33e93363..0ae6f5f8d9 100644 --- a/modules/@angular/compiler_cli/src/main.ts +++ b/modules/@angular/compiler_cli/src/main.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin / env node // Must be imported first, because angular2 decorators throws on load. import 'reflect-metadata'; diff --git a/modules/@angular/compiler_cli/src/static_reflector.ts b/modules/@angular/compiler_cli/src/static_reflector.ts index 0dbf11cfa1..d2ad0c975e 100644 --- a/modules/@angular/compiler_cli/src/static_reflector.ts +++ b/modules/@angular/compiler_cli/src/static_reflector.ts @@ -125,7 +125,7 @@ export class StaticReflector implements ReflectorReader { let parameterDecorators = this.simplify(type, ctor['parameterDecorators']); parameters = []; - parameterTypes.forEach( (paramType, index) => { + parameterTypes.forEach((paramType, index) => { let nestedResult: any[] = []; if (paramType) { nestedResult.push(paramType); @@ -152,7 +152,7 @@ export class StaticReflector implements ReflectorReader { private registerDecoratorOrConstructor(type: StaticSymbol, ctor: any): void { this.conversionMap.set(type, (context: StaticSymbol, args: any[]) => { let argValues: any[] = []; - args.forEach( (arg, index) => { + args.forEach((arg, index) => { let argValue: any; if (typeof arg === 'object' && !arg['__symbolic']) { argValue = mapStringMap(arg, (value, key) => this.simplify(context, value)); @@ -387,6 +387,6 @@ function mapStringMap(input: {[key: string]: any}, return result; } -function isPrimitive(o: any):boolean { +function isPrimitive(o: any): boolean { return o === null || (typeof o !== "function" && typeof o !== "object"); } \ No newline at end of file diff --git a/modules/@angular/compiler_cli/test/static_reflector_spec.ts b/modules/@angular/compiler_cli/test/static_reflector_spec.ts index 5f0bb86eff..f3c2b6b257 100644 --- a/modules/@angular/compiler_cli/test/static_reflector_spec.ts +++ b/modules/@angular/compiler_cli/test/static_reflector_spec.ts @@ -9,7 +9,11 @@ import { import {isBlank} from '@angular/facade/src/lang'; import {ListWrapper} from '@angular/facade/src/collection'; -import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler_cli/src/static_reflector'; +import { + StaticReflector, + StaticReflectorHost, + StaticSymbol +} from '@angular/compiler_cli/src/static_reflector'; describe('StaticReflector', () => { let noContext = new StaticSymbol('', ''); diff --git a/modules/@angular/core/src/linker/view_utils.ts b/modules/@angular/core/src/linker/view_utils.ts index 0b6cb1c53f..3ba7a5cce1 100644 --- a/modules/@angular/core/src/linker/view_utils.ts +++ b/modules/@angular/core/src/linker/view_utils.ts @@ -16,9 +16,8 @@ export class ViewUtils { sanitizer: SanitizationService; private _nextCompTypeId: number = 0; - constructor( - private _renderer: RootRenderer, @Inject(APP_ID) private _appId: string, - sanitizer: SanitizationService) { + constructor(private _renderer: RootRenderer, @Inject(APP_ID) private _appId: string, + sanitizer: SanitizationService) { this.sanitizer = sanitizer; } diff --git a/modules/@angular/core/test/linker/security_integration_spec.ts b/modules/@angular/core/test/linker/security_integration_spec.ts index 6b25762816..12a103fdc6 100644 --- a/modules/@angular/core/test/linker/security_integration_spec.ts +++ b/modules/@angular/core/test/linker/security_integration_spec.ts @@ -68,9 +68,9 @@ function declareTests(isJit: boolean) { let tpl = `
`; tcb = tcb.overrideView(SecuredComponent, new ViewMetadata({template: tpl})); PromiseWrapper.catchError(tcb.createAsync(SecuredComponent), (e) => { - expect(e.message).toContain( - `Template parse errors:\n` + `Binding to event attribute 'onclick' is disallowed ` + - `for security reasons, please use (click)=... `); + expect(e.message).toContain(`Template parse errors:\n` + + `Binding to event attribute 'onclick' is disallowed ` + + `for security reasons, please use (click)=... `); async.done(); return null; }); diff --git a/modules/@angular/router/src/directives/router_link.ts b/modules/@angular/router/src/directives/router_link.ts index 3ed2da67e8..f92659f1a0 100644 --- a/modules/@angular/router/src/directives/router_link.ts +++ b/modules/@angular/router/src/directives/router_link.ts @@ -69,7 +69,7 @@ export class RouterLink implements OnDestroy { ngOnDestroy() { ObservableWrapper.dispose(this._subscription); } @Input() - set routerLink(data: any[]|any) { + set routerLink(data: any[] | any) { if (isArray(data)) { this._commands = data; } else { diff --git a/modules/@angular/router/src/link.ts b/modules/@angular/router/src/link.ts index f79105bd4c..a22288fdf1 100644 --- a/modules/@angular/router/src/link.ts +++ b/modules/@angular/router/src/link.ts @@ -4,7 +4,8 @@ import {BaseException} from './facade/exceptions'; import {ListWrapper} from './facade/collection'; // TODO: vsavkin: should reuse segments -export function link(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree, commands: any[]): UrlTree { +export function link(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree, + commands: any[]): UrlTree { if (commands.length === 0) return urlTree; let normalizedCommands = _normalizeCommands(commands); @@ -13,24 +14,26 @@ export function link(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTr } let startingNode = _findStartingNode(normalizedCommands, urlTree, segment, routeTree); - let updated = normalizedCommands.commands.length > 0 ? - _updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) : []; + let updated = + normalizedCommands.commands.length > 0 ? + _updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) : + []; let newRoot = _constructNewTree(rootNode(urlTree), startingNode, updated); return new UrlTree(newRoot); } -function _navigateToRoot(normalizedChange:_NormalizedNavigationCommands):boolean { - return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 && normalizedChange.commands[0] == "/"; +function _navigateToRoot(normalizedChange: _NormalizedNavigationCommands): boolean { + return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 && + normalizedChange.commands[0] == "/"; } class _NormalizedNavigationCommands { - constructor(public isAbsolute: boolean, - public numberOfDoubleDots: number, + constructor(public isAbsolute: boolean, public numberOfDoubleDots: number, public commands: any[]) {} } -function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;'' +function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands { if (isString(commands[0]) && commands.length === 1 && commands[0] == "/") { return new _NormalizedNavigationCommands(true, 0, commands); } @@ -53,18 +56,18 @@ function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;'' // first exp is treated in a special way if (i == 0) { - if (j == 0 && cc == ".") { // './a' + if (j == 0 && cc == ".") { // './a' // skip it - } else if (j == 0 && cc == "") { // '/a' + } else if (j == 0 && cc == "") { // '/a' isAbsolute = true; - } else if (cc == "..") { // '../a' + } else if (cc == "..") { // '../a' numberOfDoubleDots++; } else if (cc != '') { res.push(cc); } } else { - if (cc != ''){ + if (cc != '') { res.push(cc); } } @@ -74,7 +77,8 @@ function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;'' return new _NormalizedNavigationCommands(isAbsolute, numberOfDoubleDots, res); } -function _findUrlSegment(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree, numberOfDoubleDots: number): UrlSegment { +function _findUrlSegment(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree, + numberOfDoubleDots: number): UrlSegment { let s = segment; while (s.urlSegments.length === 0) { s = routeTree.parent(s); @@ -87,11 +91,13 @@ function _findUrlSegment(segment: RouteSegment, routeTree: RouteTree, urlTree: U return path[path.length - 1 - numberOfDoubleDots]; } -function _findStartingNode(normalizedChange:_NormalizedNavigationCommands, urlTree:UrlTree, segment:RouteSegment, routeTree:RouteTree):TreeNode { +function _findStartingNode(normalizedChange: _NormalizedNavigationCommands, urlTree: UrlTree, + segment: RouteSegment, routeTree: RouteTree): TreeNode { if (normalizedChange.isAbsolute) { return rootNode(urlTree); } else { - let urlSegment = _findUrlSegment(segment, routeTree, urlTree, normalizedChange.numberOfDoubleDots); + let urlSegment = + _findUrlSegment(segment, routeTree, urlTree, normalizedChange.numberOfDoubleDots); return _findMatchingNode(urlSegment, rootNode(urlTree)); } } @@ -130,29 +136,30 @@ function _update(node: TreeNode, commands: any[]): TreeNode preserve the subtree + + // different outlet => preserve the subtree } else if (outlet != node.value.outlet) { return node; - // params command + // params command } else if (isStringMap(segment)) { let newSegment = new UrlSegment(node.value.segment, segment, node.value.outlet); return _recurse(newSegment, node, rest); - // next one is a params command + // next one is a params command } else if (isStringMap(next)) { let urlSegment = new UrlSegment(segment, next, outlet); return _recurse(urlSegment, node, rest.slice(1)); - // next one is not a params command + // next one is not a params command } else { let urlSegment = new UrlSegment(segment, {}, outlet); return _recurse(urlSegment, node, rest); } } -function _recurse(urlSegment: UrlSegment, node: TreeNode, rest: any[]): TreeNode { +function _recurse(urlSegment: UrlSegment, node: TreeNode, + rest: any[]): TreeNode { if (rest.length === 0) { return new TreeNode(urlSegment, []); } diff --git a/modules/@angular/router/src/recognize.ts b/modules/@angular/router/src/recognize.ts index 972c034b77..2ff87ce806 100644 --- a/modules/@angular/router/src/recognize.ts +++ b/modules/@angular/router/src/recognize.ts @@ -143,8 +143,7 @@ function _matchWithParts(route: RouteMetadata, url: TreeNode): _Matc } let p = lastSegment.value.parameters; - let parameters = - <{[key: string]: string}>StringMapWrapper.merge(p, positionalParams); + let parameters = <{[key: string]: string}>StringMapWrapper.merge(p, positionalParams); let axuUrlSubtrees = isPresent(lastParent) ? lastParent.children.slice(1) : []; return new _MatchResult(route.component, consumedUrlSegments, parameters, lastSegment.children, diff --git a/modules/@angular/router/src/segments.ts b/modules/@angular/router/src/segments.ts index ea2228e71e..15f2c46725 100644 --- a/modules/@angular/router/src/segments.ts +++ b/modules/@angular/router/src/segments.ts @@ -90,8 +90,8 @@ export class TreeNode { } export class UrlSegment { - constructor(public segment: any, public parameters: {[key: string]: any}, - public outlet: string) {} + constructor(public segment: any, public parameters: {[key: string]: any}, public outlet: string) { + } toString(): string { let outletPrefix = isBlank(this.outlet) ? "" : `${this.outlet}:`; diff --git a/modules/@angular/router/test/link_spec.ts b/modules/@angular/router/test/link_spec.ts index 215e6bbbed..cb9c2ee7e8 100644 --- a/modules/@angular/router/test/link_spec.ts +++ b/modules/@angular/router/test/link_spec.ts @@ -155,9 +155,9 @@ export function main() { let p = parser.parse("/a(ap)/c(cp)"); let c = p.firstChild(p.root); - let child = new RouteSegment([], {'one':1}, null, null, null); + let child = new RouteSegment([], {'one': 1}, null, null, null); let root = new TreeNode(new RouteSegment([c], {}, null, null, null), - [new TreeNode(child, [])]); + [new TreeNode(child, [])]); let tree = new RouteTree(root); let t = link(child, tree, p, ["./c2"]); diff --git a/modules/@angular/router/test/router_link_spec.ts b/modules/@angular/router/test/router_link_spec.ts index 5cde662618..c031ff3391 100644 --- a/modules/@angular/router/test/router_link_spec.ts +++ b/modules/@angular/router/test/router_link_spec.ts @@ -36,25 +36,25 @@ export function main() { RouterOutletMap, provide(Location, {useClass: SpyLocation}), provide(Router, - { - useFactory: (resolver, urlParser, outletMap, location) => new Router( - "RootComponent", RootCmp, resolver, urlParser, outletMap, location), - deps: [ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location] - }) + { + useFactory: (resolver, urlParser, outletMap, location) => new Router( + "RootComponent", RootCmp, resolver, urlParser, outletMap, location), + deps: [ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location] + }) ]); describe("routerLink=", () => { it("should accept an array of commands", inject([Router], (router) => { - let link = new RouterLink(null, router); - link.routerLink = ['/one', 11]; - expect(link.href).toEqual("/one/11"); - })); + let link = new RouterLink(null, router); + link.routerLink = ['/one', 11]; + expect(link.href).toEqual("/one/11"); + })); it("should accept a single command", inject([Router], (router) => { - let link = new RouterLink(null, router); - link.routerLink = '/one/11'; - expect(link.href).toEqual("/one/11"); - })); + let link = new RouterLink(null, router); + link.routerLink = '/one/11'; + expect(link.href).toEqual("/one/11"); + })); }); }); } diff --git a/tools/cjs-jasmine/index-tools.ts b/tools/cjs-jasmine/index-tools.ts index f662156952..32e282b6cf 100644 --- a/tools/cjs-jasmine/index-tools.ts +++ b/tools/cjs-jasmine/index-tools.ts @@ -29,13 +29,8 @@ if (globsIndex < 0) { args = process.argv.slice(globsIndex + 1); } -var specFiles = - args.map(function(globstr) { - return glob.sync(globstr, { - cwd: toolsDir - }); - }) - .reduce(function(specFiles, paths) { return specFiles.concat(paths); }, []); +var specFiles = args.map(function(globstr) { return glob.sync(globstr, {cwd: toolsDir}); }) + .reduce(function(specFiles, paths) { return specFiles.concat(paths); }, []); jasmine.DEFAULT_TIMEOUT_INTERVAL = 100; @@ -45,7 +40,5 @@ jrunner.onComplete(function(passed) { process.exit(passed ? 0 : 1); }); jrunner.projectBaseDir = path.resolve(__dirname, '../../'); jrunner.specDir = ''; require('zone.js/dist/jasmine-patch.js'); -specFiles.forEach((file) => { - toolsDirRequire(file); -}); +specFiles.forEach((file) => { toolsDirRequire(file); }); jrunner.execute(); diff --git a/tools/tsc-watch/index.ts b/tools/tsc-watch/index.ts index 558d087b5b..e49be6b8c3 100644 --- a/tools/tsc-watch/index.ts +++ b/tools/tsc-watch/index.ts @@ -11,42 +11,38 @@ const OFFLINE_COMPILE = [ 'offline_compiler_codegen_typed' ]; -function processOutputEmitterCodeGen(): - Promise { - return new Promise((resolve, reject) => { - var outDir = 'dist/all/@angular/compiler/test/'; - var promises = []; - console.log('Processing codegen...'); - OFFLINE_COMPILE.forEach((file: string) => { - var codegen = require('../../all/@angular/compiler/test/' + file + '.js'); - if (codegen.emit) { - console.log(` ${file} has changed, regenerating...`); - promises.push( - Promise.resolve(codegen.emit()) - .then((code) => { writeFileSync(outDir + file + '.ts', code); })); - } - }); - if (promises.length) { - Promise.all(promises) - .then(() => { - var args = [ - '--project', - 'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json' - ]; - console.log(' compiling changes: tsc ' + args.join(' ')); - var tsc = spawn(TSC, args, {stdio: 'pipe'}); - tsc.stdout.on('data', (data) => process.stdout.write(data)); - tsc.stderr.on('data', (data) => process.stderr.write(data)); - tsc.on('close', (code) => code ? reject('Tsc exited with: ' + code) : - resolve(code)); - }) - .catch(reportError); - } else { - resolve(0); - } - }) - .catch(reportError); - } +function processOutputEmitterCodeGen(): Promise { + return new Promise((resolve, reject) => { + var outDir = 'dist/all/@angular/compiler/test/'; + var promises = []; + console.log('Processing codegen...'); + OFFLINE_COMPILE.forEach((file: string) => { + var codegen = require('../../all/@angular/compiler/test/' + file + '.js'); + if (codegen.emit) { + console.log(` ${file} has changed, regenerating...`); + promises.push(Promise.resolve(codegen.emit()) + .then((code) => { writeFileSync(outDir + file + '.ts', code); })); + } + }); + if (promises.length) { + Promise.all(promises) + .then(() => { + var args = + ['--project', 'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json']; + console.log(' compiling changes: tsc ' + args.join(' ')); + var tsc = spawn(TSC, args, {stdio: 'pipe'}); + tsc.stdout.on('data', (data) => process.stdout.write(data)); + tsc.stderr.on('data', (data) => process.stderr.write(data)); + tsc.on('close', + (code) => code ? reject('Tsc exited with: ' + code) : resolve(code)); + }) + .catch(reportError); + } else { + resolve(0); + } + }) + .catch(reportError); +} function md(dir: string, folders: string[]) { if (folders.length) { @@ -71,7 +67,13 @@ if (platform == 'node') { complete: 'Compilation complete. Watching for file changes.', onChangeCmds: [ processOutputEmitterCodeGen, - ['node', 'dist/tools/cjs-jasmine', '--', '{@angular,benchpress}/**/*_spec.js', '@angular/compiler_cli/test/**/*_spec.js'] + [ + 'node', + 'dist/tools/cjs-jasmine', + '--', + '{@angular,benchpress}/**/*_spec.js', + '@angular/compiler_cli/test/**/*_spec.js' + ] ] }); } else if (platform == 'browser') { @@ -92,7 +94,8 @@ if (platform == 'node') { complete: 'Compilation complete. Watching for file changes.', onChangeCmds: [ // TODO: fix and enable tests for public_api_spec again! - // ['node', 'dist/tools/cjs-jasmine/index-tools', '--', '{metadata,public_api_guard}/**/*{_,.}spec.js'] + // ['node', 'dist/tools/cjs-jasmine/index-tools', '--', + // '{metadata,public_api_guard}/**/*{_,.}spec.js'] ['node', 'dist/tools/cjs-jasmine/index-tools', '--', 'metadata/**/*{_,.}spec.js'] ] });