chore: clang-format master

This commit is contained in:
Tobias Bosch 2016-05-03 18:49:59 -07:00
parent 9485f5a813
commit 0297398f5e
19 changed files with 130 additions and 118 deletions

View File

@ -55,10 +55,9 @@ export class AttrAst implements TemplateAst {
* A binding for an element property (e.g. `[property]="expression"`). * A binding for an element property (e.g. `[property]="expression"`).
*/ */
export class BoundElementPropertyAst implements TemplateAst { export class BoundElementPropertyAst implements TemplateAst {
constructor( constructor(public name: string, public type: PropertyBindingType,
public name: string, public type: PropertyBindingType, public securityContext: SecurityContext, public value: AST, public unit: string,
public securityContext: SecurityContext, public value: AST, public unit: string, public sourceSpan: ParseSourceSpan) {}
public sourceSpan: ParseSourceSpan) {}
visit(visitor: TemplateAstVisitor, context: any): any { visit(visitor: TemplateAstVisitor, context: any): any {
return visitor.visitElementProperty(this, context); return visitor.visitElementProperty(this, context);
} }

View File

@ -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; let enumValue: string;
switch (boundProp.securityContext) { switch (boundProp.securityContext) {
case SecurityContext.NONE: case SecurityContext.NONE:

View File

@ -214,7 +214,7 @@ class ViewBuilderVisitor implements TemplateAstVisitor {
var nestedComponentIdentifier = var nestedComponentIdentifier =
new CompileIdentifierMetadata({name: getViewFactoryName(component, 0)}); new CompileIdentifierMetadata({name: getViewFactoryName(component, 0)});
this.targetDependencies.push(new ViewCompileDependency(component, nestedComponentIdentifier)); this.targetDependencies.push(new ViewCompileDependency(component, nestedComponentIdentifier));
compViewExpr = o.variable(`compView_${nodeIndex}`); // fix highlighting: ` compViewExpr = o.variable(`compView_${nodeIndex}`); // fix highlighting: `
compileElement.setComponentView(compViewExpr); compileElement.setComponentView(compViewExpr);
this.view.createMethod.addStmt(compViewExpr.set(o.importExpr(nestedComponentIdentifier) this.view.createMethod.addStmt(compViewExpr.set(o.importExpr(nestedComponentIdentifier)
.callFn([ .callFn([
@ -337,7 +337,7 @@ function createViewTopLevelStmts(view: CompileView, targetStatements: o.Statemen
var nodeDebugInfosVar: o.Expression = o.NULL_EXPR; var nodeDebugInfosVar: o.Expression = o.NULL_EXPR;
if (view.genConfig.genDebugInfo) { if (view.genConfig.genDebugInfo) {
nodeDebugInfosVar = o.variable( nodeDebugInfosVar = o.variable(
`nodeDebugInfos_${view.component.type.name}${view.viewIndex}`); // fix highlighting: ` `nodeDebugInfos_${view.component.type.name}${view.viewIndex}`); // fix highlighting: `
targetStatements.push( targetStatements.push(
(<o.ReadVarExpr>nodeDebugInfosVar) (<o.ReadVarExpr>nodeDebugInfosVar)
.set(o.literalArr(view.nodes.map(createStaticNodeDebugInfo), .set(o.literalArr(view.nodes.map(createStaticNodeDebugInfo),

View File

@ -57,9 +57,8 @@ export function main() {
expect(registry.getMappedPropName('exotic-unknown')).toEqual('exotic-unknown'); expect(registry.getMappedPropName('exotic-unknown')).toEqual('exotic-unknown');
}); });
it('should return security contexts for elements', () => { it('should return security contexts for elements',
expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL); () => { expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL); });
});
it('should detect properties on namespaced elements', it('should detect properties on namespaced elements',
() => { expect(registry.hasProperty('@svg:g', 'id')).toBeTruthy(); }); () => { expect(registry.hasProperty('@svg:g', 'id')).toBeTruthy(); });

View File

@ -8,9 +8,17 @@ import * as path from 'path';
import * as compiler from '@angular/compiler'; import * as compiler from '@angular/compiler';
import {ViewEncapsulation} from '@angular/core'; import {ViewEncapsulation} from '@angular/core';
import {StaticReflector} from './static_reflector'; import {StaticReflector} from './static_reflector';
import {CompileMetadataResolver, HtmlParser, DirectiveNormalizer, Lexer, Parser, import {
TemplateParser, DomElementSchemaRegistry, StyleCompiler, CompileMetadataResolver,
ViewCompiler, TypeScriptEmitter HtmlParser,
DirectiveNormalizer,
Lexer,
Parser,
TemplateParser,
DomElementSchemaRegistry,
StyleCompiler,
ViewCompiler,
TypeScriptEmitter
} from './compiler_private'; } from './compiler_private';
import {Parse5DomAdapter} from '@angular/platform-server'; import {Parse5DomAdapter} from '@angular/platform-server';
@ -96,8 +104,7 @@ export class CodeGenerator {
let root = this.ngOptions.basePath; let root = this.ngOptions.basePath;
for (let eachRootDir of this.options.rootDirs || []) { for (let eachRootDir of this.options.rootDirs || []) {
if (this.ngOptions.trace) { if (this.ngOptions.trace) {
console.log( console.log(`Check if ${filePath} is under rootDirs element ${eachRootDir}`);
`Check if ${filePath} is under rootDirs element ${eachRootDir}`);
} }
if (path.relative(eachRootDir, filePath).indexOf('.') !== 0) { if (path.relative(eachRootDir, filePath).indexOf('.') !== 0) {
root = eachRootDir; root = eachRootDir;
@ -170,7 +177,7 @@ export class CodeGenerator {
new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector), new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector),
new compiler.ViewResolver(staticReflector), null, null, staticReflector); new compiler.ViewResolver(staticReflector), null, null, staticReflector);
return new CodeGenerator(options, ngOptions, program, compilerHost, return new CodeGenerator(options, ngOptions, program, compilerHost, staticReflector, resolver,
staticReflector, resolver, offlineCompiler, reflectorHost); offlineCompiler, reflectorHost);
} }
} }

View File

@ -25,7 +25,8 @@ export type TemplateParser = _c.TemplateParser;
export var TemplateParser: typeof _c.TemplateParser = _c.TemplateParser; export var TemplateParser: typeof _c.TemplateParser = _c.TemplateParser;
export type DomElementSchemaRegistry = _c.DomElementSchemaRegistry; 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 type StyleCompiler = _c.StyleCompiler;
export var StyleCompiler: typeof _c.StyleCompiler = _c.StyleCompiler; export var StyleCompiler: typeof _c.StyleCompiler = _c.StyleCompiler;

View File

@ -1,4 +1,4 @@
#!/usr/bin/env node #!/usr/bin / env node
// Must be imported first, because angular2 decorators throws on load. // Must be imported first, because angular2 decorators throws on load.
import 'reflect-metadata'; import 'reflect-metadata';

View File

@ -125,7 +125,7 @@ export class StaticReflector implements ReflectorReader {
let parameterDecorators = <any[]>this.simplify(type, ctor['parameterDecorators']); let parameterDecorators = <any[]>this.simplify(type, ctor['parameterDecorators']);
parameters = []; parameters = [];
parameterTypes.forEach( (paramType, index) => { parameterTypes.forEach((paramType, index) => {
let nestedResult: any[] = []; let nestedResult: any[] = [];
if (paramType) { if (paramType) {
nestedResult.push(paramType); nestedResult.push(paramType);
@ -152,7 +152,7 @@ export class StaticReflector implements ReflectorReader {
private registerDecoratorOrConstructor(type: StaticSymbol, ctor: any): void { private registerDecoratorOrConstructor(type: StaticSymbol, ctor: any): void {
this.conversionMap.set(type, (context: StaticSymbol, args: any[]) => { this.conversionMap.set(type, (context: StaticSymbol, args: any[]) => {
let argValues: any[] = []; let argValues: any[] = [];
args.forEach( (arg, index) => { args.forEach((arg, index) => {
let argValue: any; let argValue: any;
if (typeof arg === 'object' && !arg['__symbolic']) { if (typeof arg === 'object' && !arg['__symbolic']) {
argValue = mapStringMap(arg, (value, key) => this.simplify(context, value)); argValue = mapStringMap(arg, (value, key) => this.simplify(context, value));
@ -387,6 +387,6 @@ function mapStringMap(input: {[key: string]: any},
return result; return result;
} }
function isPrimitive(o: any):boolean { function isPrimitive(o: any): boolean {
return o === null || (typeof o !== "function" && typeof o !== "object"); return o === null || (typeof o !== "function" && typeof o !== "object");
} }

View File

@ -9,7 +9,11 @@ import {
import {isBlank} from '@angular/facade/src/lang'; import {isBlank} from '@angular/facade/src/lang';
import {ListWrapper} from '@angular/facade/src/collection'; 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', () => { describe('StaticReflector', () => {
let noContext = new StaticSymbol('', ''); let noContext = new StaticSymbol('', '');

View File

@ -16,9 +16,8 @@ export class ViewUtils {
sanitizer: SanitizationService; sanitizer: SanitizationService;
private _nextCompTypeId: number = 0; private _nextCompTypeId: number = 0;
constructor( constructor(private _renderer: RootRenderer, @Inject(APP_ID) private _appId: string,
private _renderer: RootRenderer, @Inject(APP_ID) private _appId: string, sanitizer: SanitizationService) {
sanitizer: SanitizationService) {
this.sanitizer = sanitizer; this.sanitizer = sanitizer;
} }

View File

@ -68,9 +68,9 @@ function declareTests(isJit: boolean) {
let tpl = `<div [attr.onclick]="ctxProp"></div>`; let tpl = `<div [attr.onclick]="ctxProp"></div>`;
tcb = tcb.overrideView(SecuredComponent, new ViewMetadata({template: tpl})); tcb = tcb.overrideView(SecuredComponent, new ViewMetadata({template: tpl}));
PromiseWrapper.catchError(tcb.createAsync(SecuredComponent), (e) => { PromiseWrapper.catchError(tcb.createAsync(SecuredComponent), (e) => {
expect(e.message).toContain( expect(e.message).toContain(`Template parse errors:\n` +
`Template parse errors:\n` + `Binding to event attribute 'onclick' is disallowed ` + `Binding to event attribute 'onclick' is disallowed ` +
`for security reasons, please use (click)=... `); `for security reasons, please use (click)=... `);
async.done(); async.done();
return null; return null;
}); });

View File

@ -69,7 +69,7 @@ export class RouterLink implements OnDestroy {
ngOnDestroy() { ObservableWrapper.dispose(this._subscription); } ngOnDestroy() { ObservableWrapper.dispose(this._subscription); }
@Input() @Input()
set routerLink(data: any[]|any) { set routerLink(data: any[] | any) {
if (isArray(data)) { if (isArray(data)) {
this._commands = <any[]>data; this._commands = <any[]>data;
} else { } else {

View File

@ -4,7 +4,8 @@ import {BaseException} from './facade/exceptions';
import {ListWrapper} from './facade/collection'; import {ListWrapper} from './facade/collection';
// TODO: vsavkin: should reuse segments // 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; if (commands.length === 0) return urlTree;
let normalizedCommands = _normalizeCommands(commands); 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 startingNode = _findStartingNode(normalizedCommands, urlTree, segment, routeTree);
let updated = normalizedCommands.commands.length > 0 ? let updated =
_updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) : []; normalizedCommands.commands.length > 0 ?
_updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) :
[];
let newRoot = _constructNewTree(rootNode(urlTree), startingNode, updated); let newRoot = _constructNewTree(rootNode(urlTree), startingNode, updated);
return new UrlTree(newRoot); return new UrlTree(newRoot);
} }
function _navigateToRoot(normalizedChange:_NormalizedNavigationCommands):boolean { function _navigateToRoot(normalizedChange: _NormalizedNavigationCommands): boolean {
return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 && normalizedChange.commands[0] == "/"; return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 &&
normalizedChange.commands[0] == "/";
} }
class _NormalizedNavigationCommands { class _NormalizedNavigationCommands {
constructor(public isAbsolute: boolean, constructor(public isAbsolute: boolean, public numberOfDoubleDots: number,
public numberOfDoubleDots: number,
public commands: any[]) {} public commands: any[]) {}
} }
function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;'' function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {
if (isString(commands[0]) && commands.length === 1 && commands[0] == "/") { if (isString(commands[0]) && commands.length === 1 && commands[0] == "/") {
return new _NormalizedNavigationCommands(true, 0, commands); return new _NormalizedNavigationCommands(true, 0, commands);
} }
@ -53,18 +56,18 @@ function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;''
// first exp is treated in a special way // first exp is treated in a special way
if (i == 0) { if (i == 0) {
if (j == 0 && cc == ".") { // './a' if (j == 0 && cc == ".") { // './a'
// skip it // skip it
} else if (j == 0 && cc == "") { // '/a' } else if (j == 0 && cc == "") { // '/a'
isAbsolute = true; isAbsolute = true;
} else if (cc == "..") { // '../a' } else if (cc == "..") { // '../a'
numberOfDoubleDots++; numberOfDoubleDots++;
} else if (cc != '') { } else if (cc != '') {
res.push(cc); res.push(cc);
} }
} else { } else {
if (cc != ''){ if (cc != '') {
res.push(cc); res.push(cc);
} }
} }
@ -74,7 +77,8 @@ function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;''
return new _NormalizedNavigationCommands(isAbsolute, numberOfDoubleDots, res); 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; let s = segment;
while (s.urlSegments.length === 0) { while (s.urlSegments.length === 0) {
s = routeTree.parent(s); s = routeTree.parent(s);
@ -87,11 +91,13 @@ function _findUrlSegment(segment: RouteSegment, routeTree: RouteTree, urlTree: U
return path[path.length - 1 - numberOfDoubleDots]; return path[path.length - 1 - numberOfDoubleDots];
} }
function _findStartingNode(normalizedChange:_NormalizedNavigationCommands, urlTree:UrlTree, segment:RouteSegment, routeTree:RouteTree):TreeNode<UrlSegment> { function _findStartingNode(normalizedChange: _NormalizedNavigationCommands, urlTree: UrlTree,
segment: RouteSegment, routeTree: RouteTree): TreeNode<UrlSegment> {
if (normalizedChange.isAbsolute) { if (normalizedChange.isAbsolute) {
return rootNode(urlTree); return rootNode(urlTree);
} else { } else {
let urlSegment = _findUrlSegment(segment, routeTree, urlTree, normalizedChange.numberOfDoubleDots); let urlSegment =
_findUrlSegment(segment, routeTree, urlTree, normalizedChange.numberOfDoubleDots);
return _findMatchingNode(urlSegment, rootNode(urlTree)); return _findMatchingNode(urlSegment, rootNode(urlTree));
} }
} }
@ -130,29 +136,30 @@ function _update(node: TreeNode<UrlSegment>, commands: any[]): TreeNode<UrlSegme
} else if (isBlank(node) && isStringMap(next)) { } else if (isBlank(node) && isStringMap(next)) {
let urlSegment = new UrlSegment(segment, next, outlet); let urlSegment = new UrlSegment(segment, next, outlet);
return _recurse(urlSegment, node, rest.slice(1)); return _recurse(urlSegment, node, rest.slice(1));
// different outlet => preserve the subtree // different outlet => preserve the subtree
} else if (outlet != node.value.outlet) { } else if (outlet != node.value.outlet) {
return node; return node;
// params command // params command
} else if (isStringMap(segment)) { } else if (isStringMap(segment)) {
let newSegment = new UrlSegment(node.value.segment, segment, node.value.outlet); let newSegment = new UrlSegment(node.value.segment, segment, node.value.outlet);
return _recurse(newSegment, node, rest); return _recurse(newSegment, node, rest);
// next one is a params command // next one is a params command
} else if (isStringMap(next)) { } else if (isStringMap(next)) {
let urlSegment = new UrlSegment(segment, next, outlet); let urlSegment = new UrlSegment(segment, next, outlet);
return _recurse(urlSegment, node, rest.slice(1)); return _recurse(urlSegment, node, rest.slice(1));
// next one is not a params command // next one is not a params command
} else { } else {
let urlSegment = new UrlSegment(segment, {}, outlet); let urlSegment = new UrlSegment(segment, {}, outlet);
return _recurse(urlSegment, node, rest); return _recurse(urlSegment, node, rest);
} }
} }
function _recurse(urlSegment: UrlSegment, node: TreeNode<UrlSegment>, rest: any[]): TreeNode<UrlSegment> { function _recurse(urlSegment: UrlSegment, node: TreeNode<UrlSegment>,
rest: any[]): TreeNode<UrlSegment> {
if (rest.length === 0) { if (rest.length === 0) {
return new TreeNode<UrlSegment>(urlSegment, []); return new TreeNode<UrlSegment>(urlSegment, []);
} }

View File

@ -143,8 +143,7 @@ function _matchWithParts(route: RouteMetadata, url: TreeNode<UrlSegment>): _Matc
} }
let p = lastSegment.value.parameters; let p = lastSegment.value.parameters;
let parameters = let parameters = <{[key: string]: string}>StringMapWrapper.merge(p, positionalParams);
<{[key: string]: string}>StringMapWrapper.merge(p, positionalParams);
let axuUrlSubtrees = isPresent(lastParent) ? lastParent.children.slice(1) : []; let axuUrlSubtrees = isPresent(lastParent) ? lastParent.children.slice(1) : [];
return new _MatchResult(route.component, consumedUrlSegments, parameters, lastSegment.children, return new _MatchResult(route.component, consumedUrlSegments, parameters, lastSegment.children,

View File

@ -90,8 +90,8 @@ export class TreeNode<T> {
} }
export class UrlSegment { export class UrlSegment {
constructor(public segment: any, public parameters: {[key: string]: any}, constructor(public segment: any, public parameters: {[key: string]: any}, public outlet: string) {
public outlet: string) {} }
toString(): string { toString(): string {
let outletPrefix = isBlank(this.outlet) ? "" : `${this.outlet}:`; let outletPrefix = isBlank(this.outlet) ? "" : `${this.outlet}:`;

View File

@ -155,9 +155,9 @@ export function main() {
let p = parser.parse("/a(ap)/c(cp)"); let p = parser.parse("/a(ap)/c(cp)");
let c = p.firstChild(p.root); 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<RouteSegment>(new RouteSegment([c], {}, null, null, null), let root = new TreeNode<RouteSegment>(new RouteSegment([c], {}, null, null, null),
[new TreeNode<RouteSegment>(child, [])]); [new TreeNode<RouteSegment>(child, [])]);
let tree = new RouteTree(root); let tree = new RouteTree(root);
let t = link(child, tree, p, ["./c2"]); let t = link(child, tree, p, ["./c2"]);

View File

@ -36,25 +36,25 @@ export function main() {
RouterOutletMap, RouterOutletMap,
provide(Location, {useClass: SpyLocation}), provide(Location, {useClass: SpyLocation}),
provide(Router, provide(Router,
{ {
useFactory: (resolver, urlParser, outletMap, location) => new Router( useFactory: (resolver, urlParser, outletMap, location) => new Router(
"RootComponent", RootCmp, resolver, urlParser, outletMap, location), "RootComponent", RootCmp, resolver, urlParser, outletMap, location),
deps: [ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location] deps: [ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location]
}) })
]); ]);
describe("routerLink=", () => { describe("routerLink=", () => {
it("should accept an array of commands", inject([Router], (router) => { it("should accept an array of commands", inject([Router], (router) => {
let link = new RouterLink(null, router); let link = new RouterLink(null, router);
link.routerLink = ['/one', 11]; link.routerLink = ['/one', 11];
expect(link.href).toEqual("/one/11"); expect(link.href).toEqual("/one/11");
})); }));
it("should accept a single command", inject([Router], (router) => { it("should accept a single command", inject([Router], (router) => {
let link = new RouterLink(null, router); let link = new RouterLink(null, router);
link.routerLink = '/one/11'; link.routerLink = '/one/11';
expect(link.href).toEqual("/one/11"); expect(link.href).toEqual("/one/11");
})); }));
}); });
}); });
} }

View File

@ -29,13 +29,8 @@ if (globsIndex < 0) {
args = process.argv.slice(globsIndex + 1); args = process.argv.slice(globsIndex + 1);
} }
var specFiles = var specFiles = args.map(function(globstr) { return glob.sync(globstr, {cwd: toolsDir}); })
args.map(function(globstr) { .reduce(function(specFiles, paths) { return specFiles.concat(paths); }, []);
return glob.sync(globstr, {
cwd: toolsDir
});
})
.reduce(function(specFiles, paths) { return specFiles.concat(paths); }, []);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100; jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
@ -45,7 +40,5 @@ jrunner.onComplete(function(passed) { process.exit(passed ? 0 : 1); });
jrunner.projectBaseDir = path.resolve(__dirname, '../../'); jrunner.projectBaseDir = path.resolve(__dirname, '../../');
jrunner.specDir = ''; jrunner.specDir = '';
require('zone.js/dist/jasmine-patch.js'); require('zone.js/dist/jasmine-patch.js');
specFiles.forEach((file) => { specFiles.forEach((file) => { toolsDirRequire(file); });
toolsDirRequire(file);
});
jrunner.execute(); jrunner.execute();

View File

@ -11,42 +11,38 @@ const OFFLINE_COMPILE = [
'offline_compiler_codegen_typed' 'offline_compiler_codegen_typed'
]; ];
function processOutputEmitterCodeGen(): function processOutputEmitterCodeGen(): Promise<number> {
Promise<number> { return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => { var outDir = 'dist/all/@angular/compiler/test/';
var outDir = 'dist/all/@angular/compiler/test/'; var promises = [];
var promises = []; console.log('Processing codegen...');
console.log('Processing codegen...'); OFFLINE_COMPILE.forEach((file: string) => {
OFFLINE_COMPILE.forEach((file: string) => { var codegen = require('../../all/@angular/compiler/test/' + file + '.js');
var codegen = require('../../all/@angular/compiler/test/' + file + '.js'); if (codegen.emit) {
if (codegen.emit) { console.log(` ${file} has changed, regenerating...`);
console.log(` ${file} has changed, regenerating...`); promises.push(Promise.resolve(codegen.emit())
promises.push( .then((code) => { writeFileSync(outDir + file + '.ts', code); }));
Promise.resolve(codegen.emit()) }
.then((code) => { writeFileSync(outDir + file + '.ts', code); })); });
} if (promises.length) {
}); Promise.all(promises)
if (promises.length) { .then(() => {
Promise.all(promises) var args =
.then(() => { ['--project', 'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json'];
var args = [ console.log(' compiling changes: tsc ' + args.join(' '));
'--project', var tsc = spawn(TSC, args, {stdio: 'pipe'});
'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json' tsc.stdout.on('data', (data) => process.stdout.write(data));
]; tsc.stderr.on('data', (data) => process.stderr.write(data));
console.log(' compiling changes: tsc ' + args.join(' ')); tsc.on('close',
var tsc = spawn(TSC, args, {stdio: 'pipe'}); (code) => code ? reject('Tsc exited with: ' + code) : resolve(code));
tsc.stdout.on('data', (data) => process.stdout.write(data)); })
tsc.stderr.on('data', (data) => process.stderr.write(data)); .catch(reportError);
tsc.on('close', (code) => code ? reject('Tsc exited with: ' + code) : } else {
resolve(code)); resolve(0);
}) }
.catch(reportError); })
} else { .catch(reportError);
resolve(0); }
}
})
.catch(reportError);
}
function md(dir: string, folders: string[]) { function md(dir: string, folders: string[]) {
if (folders.length) { if (folders.length) {
@ -71,7 +67,13 @@ if (platform == 'node') {
complete: 'Compilation complete. Watching for file changes.', complete: 'Compilation complete. Watching for file changes.',
onChangeCmds: [ onChangeCmds: [
processOutputEmitterCodeGen, 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') { } else if (platform == 'browser') {
@ -92,7 +94,8 @@ if (platform == 'node') {
complete: 'Compilation complete. Watching for file changes.', complete: 'Compilation complete. Watching for file changes.',
onChangeCmds: [ onChangeCmds: [
// TODO: fix and enable tests for public_api_spec again! // 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'] ['node', 'dist/tools/cjs-jasmine/index-tools', '--', 'metadata/**/*{_,.}spec.js']
] ]
}); });