diff --git a/README.md b/README.md index b153f2763..592162e72 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,9 @@ Most TypeScript-related options should be set using a file. There are a few loader-specific options you can set although in general you should not need to. +##### silent *(boolean) (default='false')* +If true, no console.log messages will be emitted. + ##### compiler *(string) (default='typescript')* Allows use of TypeScript compilers other than the official one. Should be diff --git a/index.ts b/index.ts index 2a81d7e9c..a5f064a58 100644 --- a/index.ts +++ b/index.ts @@ -21,6 +21,7 @@ interface Dependency { } interface Options { + silent: boolean; instance: string; compiler: string; configFileName: string; @@ -86,6 +87,12 @@ function findConfigFile(compiler: typeof typescript, searchPath: string, configF function ensureTypeScriptInstance(options: Options, loader: any): TSInstance { + function log(...messages: string[]): void { + if (!options.silent) { + console.log.apply(console, messages); + } + } + var compiler = require(options.compiler); var files = {}; @@ -100,7 +107,7 @@ function ensureTypeScriptInstance(options: Options, loader: any): TSInstance { var filesToLoad = []; var configFilePath = findConfigFile(compiler, path.dirname(loader.resourcePath), options.configFileName); if (configFilePath) { - console.log('Using config file at '.green + configFilePath.blue); + log('Using config file at '.green + configFilePath.blue); var configFile = compiler.readConfigFile(configFilePath); // TODO: when 1.5 stable comes out, this will never be undefined. Instead it will // have an 'error' property @@ -166,7 +173,7 @@ function ensureTypeScriptInstance(options: Options, loader: any): TSInstance { getCompilationSettings: () => compilerOptions, getDefaultLibFileName: options => libFileName, getNewLine: () => { return os.EOL }, - log: message => console.log(message) + log: log }; var languageService = compiler.createLanguageService(servicesHost, compiler.createDocumentRegistry()) @@ -280,4 +287,4 @@ function loader(contents) { callback(null, contents, sourceMap) } -export = loader; \ No newline at end of file +export = loader; diff --git a/package.json b/package.json index d61d43f27..d8f62731f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "0.4.4", + "version": "0.4.5", "description": "TypeScript loader for webpack", "main": "index.js", "scripts": {