From dfd8140084d8f172c2cbefe63febce6735dc2c3a Mon Sep 17 00:00:00 2001 From: Bowen Ni Date: Wed, 30 Nov 2016 16:45:40 -0800 Subject: [PATCH] Fix format --- modules/@angular/compiler-cli/src/main.ts | 5 ++-- .../@angular/compiler-cli/test/main_spec.ts | 29 ++++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/modules/@angular/compiler-cli/src/main.ts b/modules/@angular/compiler-cli/src/main.ts index f8832997b2..9ec4a6c7ba 100644 --- a/modules/@angular/compiler-cli/src/main.ts +++ b/modules/@angular/compiler-cli/src/main.ts @@ -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 { +export function main( + args: any, consoleError: (s: string) => void = console.error): Promise { 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)); -} \ No newline at end of file +} diff --git a/modules/@angular/compiler-cli/test/main_spec.ts b/modules/@angular/compiler-cli/test/main_spec.ts index df0c0e4491..a0f9948db6 100644 --- a/modules/@angular/compiler-cli/test/main_spec.ts +++ b/modules/@angular/compiler-cli/test/main_spec.ts @@ -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)); }); -}); \ No newline at end of file +});