chore: clang-format master
This commit is contained in:
parent
9485f5a813
commit
0297398f5e
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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(
|
||||
(<o.ReadVarExpr>nodeDebugInfosVar)
|
||||
.set(o.literalArr(view.nodes.map(createStaticNodeDebugInfo),
|
||||
|
|
|
@ -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(); });
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -125,7 +125,7 @@ export class StaticReflector implements ReflectorReader {
|
|||
let parameterDecorators = <any[]>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");
|
||||
}
|
|
@ -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('', '');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,9 +68,9 @@ function declareTests(isJit: boolean) {
|
|||
let tpl = `<div [attr.onclick]="ctxProp"></div>`;
|
||||
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;
|
||||
});
|
||||
|
|
|
@ -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 = <any[]>data;
|
||||
} else {
|
||||
|
|
|
@ -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<UrlSegment> {
|
||||
function _findStartingNode(normalizedChange: _NormalizedNavigationCommands, urlTree: UrlTree,
|
||||
segment: RouteSegment, routeTree: RouteTree): TreeNode<UrlSegment> {
|
||||
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<UrlSegment>, commands: any[]): TreeNode<UrlSegme
|
|||
} else if (isBlank(node) && isStringMap(next)) {
|
||||
let urlSegment = new UrlSegment(segment, next, outlet);
|
||||
return _recurse(urlSegment, node, rest.slice(1));
|
||||
|
||||
// different outlet => 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<UrlSegment>, rest: any[]): TreeNode<UrlSegment> {
|
||||
function _recurse(urlSegment: UrlSegment, node: TreeNode<UrlSegment>,
|
||||
rest: any[]): TreeNode<UrlSegment> {
|
||||
if (rest.length === 0) {
|
||||
return new TreeNode<UrlSegment>(urlSegment, []);
|
||||
}
|
||||
|
|
|
@ -143,8 +143,7 @@ function _matchWithParts(route: RouteMetadata, url: TreeNode<UrlSegment>): _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,
|
||||
|
|
|
@ -90,8 +90,8 @@ export class TreeNode<T> {
|
|||
}
|
||||
|
||||
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}:`;
|
||||
|
|
|
@ -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<RouteSegment>(new RouteSegment([c], {}, null, null, null),
|
||||
[new TreeNode<RouteSegment>(child, [])]);
|
||||
[new TreeNode<RouteSegment>(child, [])]);
|
||||
let tree = new RouteTree(root);
|
||||
|
||||
let t = link(child, tree, p, ["./c2"]);
|
||||
|
|
|
@ -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");
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -11,42 +11,38 @@ const OFFLINE_COMPILE = [
|
|||
'offline_compiler_codegen_typed'
|
||||
];
|
||||
|
||||
function processOutputEmitterCodeGen():
|
||||
Promise<number> {
|
||||
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<number> {
|
||||
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']
|
||||
]
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue