chore: clang-reformat

This commit is contained in:
Misko Hevery
2016-05-01 22:50:37 -07:00
parent bb8976608d
commit 3e17c99f4e
108 changed files with 1120 additions and 1129 deletions

View File

@ -31,28 +31,28 @@ if (globsIndex < 0) {
args = process.argv.slice(globsIndex + 1);
}
var specFiles = args.map(function(globstr) {
return glob.sync(globstr, {
cwd: distAll,
ignore: [
// the following code and tests are not compatible with CJS/node environment
'@angular/platform-browser/**',
'@angular/platform-browser-dynamic/**',
'@angular/core/test/zone/**',
'@angular/core/test/fake_async_spec.*',
'@angular/common/test/forms/**',
'@angular/router/test/route_config/route_config_spec.*',
'@angular/router/test/integration/bootstrap_spec.*',
'@angular/integration_test/symbol_inspector/**',
'@angular/upgrade/**',
'@angular/examples/**',
'angular1_router/**',
'payload_tests/**'
]
});
}).reduce(function(specFiles, paths) {
return specFiles.concat(paths);
}, []);
var specFiles =
args.map(function(globstr) {
return glob.sync(globstr, {
cwd: distAll,
ignore: [
// the following code and tests are not compatible with CJS/node environment
'@angular/platform-browser/**',
'@angular/platform-browser-dynamic/**',
'@angular/core/test/zone/**',
'@angular/core/test/fake_async_spec.*',
'@angular/common/test/forms/**',
'@angular/router/test/route_config/route_config_spec.*',
'@angular/router/test/integration/bootstrap_spec.*',
'@angular/integration_test/symbol_inspector/**',
'@angular/upgrade/**',
'@angular/examples/**',
'angular1_router/**',
'payload_tests/**'
]
});
})
.reduce(function(specFiles, paths) { return specFiles.concat(paths); }, []);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
@ -69,4 +69,3 @@ specFiles.forEach((file) => {
if (r.main) r.main();
});
jrunner.execute();

View File

@ -2,4 +2,4 @@ var testingPlatformServer = require('../../all/@angular/platform-server/testing/
var testing = require('../../all/@angular/core/testing');
testing.setBaseTestProviders(testingPlatformServer.TEST_SERVER_PLATFORM_PROVIDERS,
testingPlatformServer.TEST_SERVER_APPLICATION_PROVIDERS);
testingPlatformServer.TEST_SERVER_APPLICATION_PROVIDERS);

View File

@ -1,6 +1,13 @@
/// <reference path="../../typings/jasmine/jasmine.d.ts" />
import {describe, it, iit, expect, ddescribe, beforeEach} from '@angular/core/testing/testing_internal';
import {
describe,
it,
iit,
expect,
ddescribe,
beforeEach
} from '@angular/core/testing/testing_internal';
import {isBlank} from '@angular/facade/src/lang';
import {ListWrapper} from '@angular/facade/src/collection';

View File

@ -4,41 +4,51 @@ import {writeFileSync, mkdirSync, existsSync} from 'fs';
export * from './tsc_watch';
import 'reflect-metadata';
const OFFLINE_COMPILE = [
'output/output_emitter_codegen_untyped',
'output/output_emitter_codegen_typed',
'offline_compiler_codegen_untyped',
'offline_compiler_codegen_typed'
]
const OFFLINE_COMPILE =
[
'output/output_emitter_codegen_untyped',
'output/output_emitter_codegen_typed',
'offline_compiler_codegen_untyped',
'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) {
@ -72,12 +82,9 @@ if (platform == 'node') {
start: 'File change detected. Starting incremental compilation...',
error: 'error',
complete: 'Compilation complete. Watching for file changes.',
onStartCmds: [
['node', 'node_modules/karma/bin/karma', 'start', '--no-auto-watch', 'karma-js.conf.js']
],
onChangeCmds: [
['node', 'node_modules/karma/bin/karma', 'run', 'karma-js.conf.js']
]
onStartCmds:
[['node', 'node_modules/karma/bin/karma', 'start', '--no-auto-watch', 'karma-js.conf.js']],
onChangeCmds: [['node', 'node_modules/karma/bin/karma', 'run', 'karma-js.conf.js']]
});
}

View File

@ -2,27 +2,33 @@ import {spawn} from 'child_process';
import {resolve} from 'url';
enum State {
idle, waiting, error
idle,
waiting,
error
}
export const TSC = 'node_modules/typescript/bin/tsc';
export type Command = (stdIn, stdErr) => Promise<number>;
export class TscWatch {
private tsconfig:string;
private start:string|RegExp;
private error:string|RegExp;
private complete:string|RegExp;
private onStartCmds:Array<string[]|Command>;
private onChangeCmds:Array<string[]|Command>;
private state:State;
private triggered:Promise<number> = null;
private tsconfig: string;
private start: string | RegExp;
private error: string | RegExp;
private complete: string | RegExp;
private onStartCmds: Array<string[] | Command>;
private onChangeCmds: Array<string[] | Command>;
private state: State;
private triggered: Promise<number> = null;
private runOnce: boolean = false;
constructor({tsconfig, start, error, complete, onStartCmds=null, onChangeCmds=null}:
{tsconfig:string, error:string|RegExp, start:string, complete:string,
onStartCmds?:Array<string[]|Command>, onChangeCmds?:Array<string[]|Command>})
{
constructor({tsconfig, start, error, complete, onStartCmds = null, onChangeCmds = null}: {
tsconfig: string,
error: string | RegExp,
start: string,
complete: string,
onStartCmds?: Array<string[] | Command>,
onChangeCmds?: Array<string[] | Command>
}) {
console.log('Watching:', tsconfig, 'in', process.cwd());
this.tsconfig = tsconfig;
this.start = start;
@ -35,7 +41,8 @@ export class TscWatch {
watch() {
var args = [TSC, '--project', this.tsconfig];
if (!this.runOnce) args.push('--watch');
var tsc = this.runCmd(args, {}, (d) => this.consumeLine(d, false), (d) => this.consumeLine(d, true));
var tsc =
this.runCmd(args, {}, (d) => this.consumeLine(d, false), (d) => this.consumeLine(d, true));
if (this.runOnce) {
tsc.then(() => this.triggerCmds(), code => process.exit(code));
}
@ -43,27 +50,27 @@ export class TscWatch {
this.onStartCmds.forEach((cmd) => this.runCmd(cmd, () => null, () => null));
}
private runCmd(argsOrCmd: string[]|Command, env?,
stdOut = pipeStdOut, stdErr = pipeStdErr):Promise<number>
{
private runCmd(argsOrCmd: string[] | Command, env?, stdOut = pipeStdOut,
stdErr = pipeStdErr): Promise<number> {
if (typeof argsOrCmd == 'function') {
return (argsOrCmd as Command)(stdErr, stdOut);
} else if (argsOrCmd instanceof Array) {
var args = argsOrCmd as Array<string>;
return <any>new Promise((resolve, reject) => {
var [cmd, ...options] = args;
console.log('=====>', cmd, options.join(' '));
var childProcess = spawn(cmd, options, {stdio: 'pipe'});
childProcess.stdout.on('data', stdOut);
childProcess.stderr.on('data', stdErr);
var onExit = () => childProcess.kill();
childProcess.on('close', (code: number) => {
process.removeListener('exit', onExit);
console.log('EXIT:', code, '<=====', args.join(' '));
code ? reject(code) : resolve(code);
});
process.on('exit', onExit);
}).catch(reportError);
var [cmd, ...options] = args;
console.log('=====>', cmd, options.join(' '));
var childProcess = spawn(cmd, options, {stdio: 'pipe'});
childProcess.stdout.on('data', stdOut);
childProcess.stderr.on('data', stdErr);
var onExit = () => childProcess.kill();
childProcess.on('close', (code: number) => {
process.removeListener('exit', onExit);
console.log('EXIT:', code, '<=====', args.join(' '));
code ? reject(code) : resolve(code);
});
process.on('exit', onExit);
})
.catch(reportError);
} else {
throw new Error('Expecting function or an array of strings...');
}
@ -74,7 +81,7 @@ export class TscWatch {
this.watch();
}
consumeLine(buffer:Buffer, isStdError:boolean) {
consumeLine(buffer: Buffer, isStdError: boolean) {
var line = '' + buffer;
if (contains(line, this.start)) {
console.log('==============================================================================');
@ -92,7 +99,8 @@ export class TscWatch {
this.state = State.idle;
} else {
if (this.triggered) {
this.triggered.then(() => this.triggerCmds(), (e) => {console.log("Error while running commands....", e)});
this.triggered.then(() => this.triggerCmds(),
(e) => {console.log("Error while running commands....", e)});
} else {
this.triggerCmds();
}
@ -103,12 +111,10 @@ export class TscWatch {
}
triggerCmds() {
var cmdPromise:Promise<number> = Promise.resolve();
this.onChangeCmds.forEach((cmd:string[]|Command) => {
cmdPromise = cmdPromise.then(() => {
return this.runCmd(<string[]>cmd);
})
});
var cmdPromise: Promise<number> = Promise.resolve();
this.onChangeCmds.forEach((cmd: string[] | Command) => {cmdPromise = cmdPromise.then(() => {
return this.runCmd(<string[]>cmd);
})});
cmdPromise.then(() => this.triggered = null, (code) => {
if (this.runOnce) {
if (typeof code != 'number') {
@ -116,7 +122,7 @@ export class TscWatch {
process.exit(1);
}
process.exit(code);
} else {
} else {
this.triggered = null;
}
});
@ -124,7 +130,7 @@ export class TscWatch {
}
}
function stdOut(data:Buffer, isStdError:boolean) {
function stdOut(data: Buffer, isStdError: boolean) {
if (isStdError) {
process.stderr.write(data);
} else {
@ -132,7 +138,7 @@ function stdOut(data:Buffer, isStdError:boolean) {
}
}
function contains(line: string, text: string| RegExp): boolean {
function contains(line: string, text: string | RegExp): boolean {
if (typeof text == 'string') {
return line.indexOf(text as string) != -1;
} else if (text instanceof RegExp) {
@ -153,5 +159,9 @@ export function reportError(e) {
return Promise.reject(e);
}
function pipeStdOut(d) { process.stdout.write(d); }
function pipeStdErr(d) { process.stderr.write(d); }
function pipeStdOut(d) {
process.stdout.write(d);
}
function pipeStdErr(d) {
process.stderr.write(d);
}