Fix format

This commit is contained in:
Bowen Ni 2016-11-30 16:45:40 -08:00 committed by Alex Rickabaugh
parent 6ea3ab7e14
commit dfd8140084
2 changed files with 24 additions and 10 deletions

View File

@ -22,7 +22,8 @@ function codegen(
return CodeGenerator.create(ngOptions, cliOptions, program, host).codegen();
}
export function main(args: any, consoleError: (s: string) => void = console.error): Promise<number> {
export function main(
args: any, consoleError: (s: string) => void = console.error): Promise<number> {
const project = args.p || args.project || '.';
const cliOptions = new tsc.NgcCliOptions(args);
@ -42,4 +43,4 @@ export function main(args: any, consoleError: (s: string) => void = console.erro
if (require.main === module) {
const args = require('minimist')(process.argv.slice(2));
main(args).then((exitCode: number) => process.exit(exitCode));
}
}

View File

@ -64,7 +64,9 @@ describe('compiler-cli', () => {
main({p: basePath}, mockConsole.error)
.then((exitCode) => {
expect(mockConsole.error).toHaveBeenCalledWith(`Error File '` + path.join(basePath, 'test.ts') + `' not found.`);
expect(mockConsole.error)
.toHaveBeenCalledWith(
`Error File '` + path.join(basePath, 'test.ts') + `' not found.`);
expect(mockConsole.error).not.toHaveBeenCalledWith('Compilation failed');
expect(exitCode).toEqual(1);
done();
@ -81,7 +83,9 @@ describe('compiler-cli', () => {
main({p: basePath}, mockConsole.error)
.then((exitCode) => {
expect(mockConsole.error).toHaveBeenCalledWith('Error at ' + path.join(basePath, 'test.ts') + `:1:1: Cannot find name 'foo'.`);
expect(mockConsole.error)
.toHaveBeenCalledWith(
'Error at ' + path.join(basePath, 'test.ts') + `:1:1: Cannot find name 'foo'.`);
expect(mockConsole.error).not.toHaveBeenCalledWith('Compilation failed');
expect(exitCode).toEqual(1);
done();
@ -90,7 +94,7 @@ describe('compiler-cli', () => {
});
it('should not print the stack trace if cannot find the imported module', (done) => {
write('test.ts', "import {MyClass} from './not-exist-deps';");
write('test.ts', `import {MyClass} from './not-exist-deps';`);
const mockConsole = {error: (s: string) => {}};
@ -98,7 +102,10 @@ describe('compiler-cli', () => {
main({p: basePath}, mockConsole.error)
.then((exitCode) => {
expect(mockConsole.error).toHaveBeenCalledWith('Error at ' + path.join(basePath, 'test.ts') + `:1:23: Cannot find module './not-exist-deps'.`);
expect(mockConsole.error)
.toHaveBeenCalledWith(
'Error at ' + path.join(basePath, 'test.ts') +
`:1:23: Cannot find module './not-exist-deps'.`);
expect(mockConsole.error).not.toHaveBeenCalledWith('Compilation failed');
expect(exitCode).toEqual(1);
done();
@ -108,7 +115,7 @@ describe('compiler-cli', () => {
it('should not print the stack trace if cannot import', (done) => {
write('empty-deps.ts', 'export const A = 1;');
write('test.ts', "import {MyClass} from './empty-deps';");
write('test.ts', `import {MyClass} from './empty-deps';`);
const mockConsole = {error: (s: string) => {}};
@ -116,7 +123,10 @@ describe('compiler-cli', () => {
main({p: basePath}, mockConsole.error)
.then((exitCode) => {
expect(mockConsole.error).toHaveBeenCalledWith('Error at ' + path.join(basePath, 'test.ts') + `:1:9: Module '"` + path.join(basePath, 'empty-deps') + `"' has no exported member 'MyClass'.`);
expect(mockConsole.error)
.toHaveBeenCalledWith(
'Error at ' + path.join(basePath, 'test.ts') + `:1:9: Module '"` +
path.join(basePath, 'empty-deps') + `"' has no exported member 'MyClass'.`);
expect(mockConsole.error).not.toHaveBeenCalledWith('Compilation failed');
expect(exitCode).toEqual(1);
done();
@ -137,7 +147,10 @@ describe('compiler-cli', () => {
main({p: basePath}, mockConsole.error)
.then((exitCode) => {
expect(mockConsole.error).toHaveBeenCalledWith('Error at ' + path.join(basePath, 'test.ts') + ':3:7: Cannot invoke an expression whose type lacks a call signature.');
expect(mockConsole.error)
.toHaveBeenCalledWith(
'Error at ' + path.join(basePath, 'test.ts') +
':3:7: Cannot invoke an expression whose type lacks a call signature.');
expect(mockConsole.error).not.toHaveBeenCalledWith('Compilation failed');
expect(exitCode).toEqual(1);
done();
@ -161,4 +174,4 @@ describe('compiler-cli', () => {
})
.catch(e => done.fail(e));
});
});
});