diff --git a/README.md b/README.md index dbcea723..2119b613 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # serverless-plugin-typescript [![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![npm version](https://badge.fury.io/js/serverless-plugin-typescript.svg)](https://badge.fury.io/js/serverless-plugin-typescript) [![Build Status](https://travis-ci.org/prisma/serverless-plugin-typescript.svg?branch=master)](https://travis-ci.org/prisma/serverless-plugin-typescript) -Serverless plugin for zero-config Typescript support +Serverless plugin for zero-config TypeScript support ## Features @@ -84,10 +84,10 @@ compilation begins, it will check to see that the file indicated exists with a ### Automatic compilation -The normal Serverless deploy procedure will automatically compile with Typescript: +The normal Serverless deploy procedure will automatically compile with TypeScript: - Create the Serverless project with `serverless create -t aws-nodejs` -- Install Serverless Typescript as above +- Install Serverless TypeScript as above - Deploy with `serverless deploy` ### Usage with serverless-offline diff --git a/src/index.ts b/src/index.ts index a249ce58..6c94ee09 100644 --- a/src/index.ts +++ b/src/index.ts @@ -136,7 +136,7 @@ export class TypeScriptPlugin { async compileTs(): Promise { this.prepare() - this.serverless.cli.log('Compiling with Typescript...') + this.serverless.cli.log('Compiling with TypeScript...') if (!this.originalServicePath) { // Save original service path and functions @@ -145,7 +145,7 @@ export class TypeScriptPlugin { this.serverless.config.servicePath = path.join(this.originalServicePath, BUILD_FOLDER) } - const tsconfig = typescript.getTypescriptConfig( + const tsconfig = typescript.getTypeScriptConfig( this.originalServicePath, this.isWatching ? null : this.serverless.cli ) @@ -153,7 +153,7 @@ export class TypeScriptPlugin { tsconfig.outDir = BUILD_FOLDER const emitedFiles = await typescript.run(this.rootFileNames, tsconfig) - this.serverless.cli.log('Typescript compiled.') + this.serverless.cli.log('TypeScript compiled.') return emitedFiles } diff --git a/src/typescript.ts b/src/typescript.ts index 22f7354a..c0526648 100644 --- a/src/typescript.ts +++ b/src/typescript.ts @@ -3,8 +3,8 @@ import * as fs from 'fs-extra' import * as _ from 'lodash' import * as path from 'path' -export function makeDefaultTypescriptConfig() { - const defaultTypescriptConfig: ts.CompilerOptions = { +export function makeDefaultTypeScriptConfig() { + const defaultTypeScriptConfig: ts.CompilerOptions = { preserveConstEnums: true, strictNullChecks: true, sourceMap: true, @@ -15,7 +15,7 @@ export function makeDefaultTypescriptConfig() { rootDir: './', } - return defaultTypescriptConfig + return defaultTypeScriptConfig } export function extractFileNames(cwd: string, provider: string, functions?: { [key: string]: Serverless.Function }): string[] { @@ -39,7 +39,7 @@ export function extractFileNames(cwd: string, provider: string, functions?: { [k // Check that the file indeed exists. if (!fs.existsSync(path.join(cwd, main))) { console.log(`Cannot locate entrypoint, ${main} not found`) - throw new Error('Typescript compilation failed') + throw new Error('TypeScript compilation failed') } return [main] @@ -66,7 +66,7 @@ export function extractFileNames(cwd: string, provider: string, functions?: { [k // Can't find the files. Watch will have an exception anyway. So throw one with error. console.log(`Cannot locate handler - ${fileName} not found`) - throw new Error('Typescript compilation failed. Please ensure handlers exists with ext .ts or .js') + throw new Error('TypeScript compilation failed. Please ensure handlers exists with ext .ts or .js') }) } @@ -88,7 +88,7 @@ export async function run(fileNames: string[], options: ts.CompilerOptions): Pro }) if (emitResult.emitSkipped) { - throw new Error('Typescript compilation failed') + throw new Error('TypeScript compilation failed') } return emitResult.emittedFiles.filter(filename => filename.endsWith('.js')) @@ -110,7 +110,7 @@ export function getSourceFiles( return programmFiles } -export function getTypescriptConfig( +export function getTypeScriptConfig( cwd: string, logger?: { log: (str: string) => void } ): ts.CompilerOptions { @@ -142,5 +142,5 @@ export function getTypescriptConfig( return configParseResult.options } - return makeDefaultTypescriptConfig() + return makeDefaultTypeScriptConfig() } diff --git a/src/watchFiles.ts b/src/watchFiles.ts index a231534a..1a55f16c 100644 --- a/src/watchFiles.ts +++ b/src/watchFiles.ts @@ -2,7 +2,7 @@ import * as typescript from './typescript' import { watchFile, unwatchFile, Stats} from 'fs' export function watchFiles(rootFileNames: string[], originalServicePath: string, cb: () => void) { - const tsConfig = typescript.getTypescriptConfig(originalServicePath) + const tsConfig = typescript.getTypeScriptConfig(originalServicePath) let watchedFiles = typescript.getSourceFiles(rootFileNames, tsConfig) watchedFiles.forEach(fileName => { diff --git a/tests/typescript.getTypescriptConfig.test.ts b/tests/typescript.getTypescriptConfig.test.ts index da80c772..3cb5df8c 100644 --- a/tests/typescript.getTypescriptConfig.test.ts +++ b/tests/typescript.getTypescriptConfig.test.ts @@ -1,11 +1,11 @@ -import {getTypescriptConfig, makeDefaultTypescriptConfig} from '../src/typescript' +import {getTypeScriptConfig, makeDefaultTypeScriptConfig} from '../src/typescript' -describe('getTypescriptConfig', () => { +describe('getTypeScriptConfig', () => { it(`returns default typescript configuration if the one provided doesn't exist`, () => { expect( - getTypescriptConfig('/ciaone/my-folder'), + getTypeScriptConfig('/ciaone/my-folder'), ).toEqual( - makeDefaultTypescriptConfig() + makeDefaultTypeScriptConfig() ) }) }) \ No newline at end of file