@wessberg/rollup-plugin-ts
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -0,1 +1,10 @@ | ||
<a name="0.0.3"></a> | ||
## <small>0.0.3 (2018-03-29)</small> | ||
* 0.0.3 ([daebd39](https://github.com/wessberg/rollup-plugin-ts/commit/daebd39)) | ||
* Bumped version ([df57378](https://github.com/wessberg/rollup-plugin-ts/commit/df57378)) | ||
* Fixed a few bugs ([c461476](https://github.com/wessberg/rollup-plugin-ts/commit/c461476)) | ||
<a name="0.0.2"></a> | ||
@@ -2,0 +11,0 @@ ## <small>0.0.2 (2018-03-29)</small> |
@@ -42,5 +42,5 @@ import { InputOptions, OutputOptions } from "rollup"; | ||
* Prints the given Diagnostic | ||
* @param {Diagnostic[]} diagnostic | ||
* @param {ReadonlyArray<Diagnostic>} diagnostics | ||
* @param {FormatHost} formatHost | ||
*/ | ||
export declare function printDiagnostic(diagnostic: Diagnostic, formatHost: FormatHost): void; | ||
export declare function printDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, formatHost: FormatHost): void; |
@@ -104,17 +104,28 @@ "use strict"; | ||
* Prints the given Diagnostic | ||
* @param {Diagnostic[]} diagnostic | ||
* @param {ReadonlyArray<Diagnostic>} diagnostics | ||
* @param {FormatHost} formatHost | ||
*/ | ||
function printDiagnostic(diagnostic, formatHost) { | ||
const formatted = typescript_1.formatDiagnostic(diagnostic, formatHost); | ||
switch (diagnostic.category) { | ||
case typescript_1.DiagnosticCategory.Message: | ||
return console.info(chalk_1.default.white(formatted)); | ||
case typescript_1.DiagnosticCategory.Warning: | ||
return console.warn(chalk_1.default.yellow(formatted)); | ||
case typescript_1.DiagnosticCategory.Error: | ||
throw new Error(chalk_1.default.red(formatted)); | ||
function printDiagnostics(diagnostics, formatHost) { | ||
// Take all errors | ||
const [firstError, ...otherErrors] = diagnostics.filter(diagnostic => diagnostic.category === typescript_1.DiagnosticCategory.Error); | ||
// Take everything else | ||
const rest = [...otherErrors, ...diagnostics.filter(diagnostic => diagnostic.category !== typescript_1.DiagnosticCategory.Error)]; | ||
// Walk through all diagnostics that isn't errors | ||
for (const diagnostic of rest) { | ||
const formatted = typescript_1.formatDiagnostic(diagnostic, formatHost); | ||
switch (diagnostic.category) { | ||
case typescript_1.DiagnosticCategory.Message: | ||
return console.info(chalk_1.default.white(formatted)); | ||
case typescript_1.DiagnosticCategory.Warning: | ||
return console.warn(chalk_1.default.yellow(formatted)); | ||
case typescript_1.DiagnosticCategory.Error: | ||
return console.warn(chalk_1.default.red(formatted)); | ||
} | ||
} | ||
// Format and throw the first error, if there is any | ||
if (firstError != null) { | ||
throw new Error(chalk_1.default.red(typescript_1.formatDiagnostic(firstError, formatHost))); | ||
} | ||
} | ||
exports.printDiagnostic = printDiagnostic; | ||
exports.printDiagnostics = printDiagnostics; | ||
//# sourceMappingURL=helpers.js.map |
@@ -64,5 +64,3 @@ "use strict"; | ||
if (formatHost != null) { | ||
for (const diagnostic of languageServiceHost.getAllDiagnostics()) { | ||
helpers_1.printDiagnostic(diagnostic, formatHost); | ||
} | ||
helpers_1.printDiagnostics(languageServiceHost.getAllDiagnostics(), formatHost); | ||
} | ||
@@ -95,3 +93,3 @@ // Do no more if the compiler options are somehow not defined | ||
// Assert that the file passes the filter | ||
if (!filter(file)) { | ||
if (!filter(file) || !file.endsWith(constants_1.TYPESCRIPT_EXTENSION)) { | ||
return undefined; | ||
@@ -98,0 +96,0 @@ } |
@@ -42,5 +42,5 @@ import { InputOptions, OutputOptions } from "rollup"; | ||
* Prints the given Diagnostic | ||
* @param {Diagnostic[]} diagnostic | ||
* @param {ReadonlyArray<Diagnostic>} diagnostics | ||
* @param {FormatHost} formatHost | ||
*/ | ||
export declare function printDiagnostic(diagnostic: Diagnostic, formatHost: FormatHost): void; | ||
export declare function printDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, formatHost: FormatHost): void; |
@@ -97,16 +97,27 @@ import chalk from "chalk"; | ||
* Prints the given Diagnostic | ||
* @param {Diagnostic[]} diagnostic | ||
* @param {ReadonlyArray<Diagnostic>} diagnostics | ||
* @param {FormatHost} formatHost | ||
*/ | ||
export function printDiagnostic(diagnostic, formatHost) { | ||
const formatted = formatDiagnostic(diagnostic, formatHost); | ||
switch (diagnostic.category) { | ||
case DiagnosticCategory.Message: | ||
return console.info(chalk.white(formatted)); | ||
case DiagnosticCategory.Warning: | ||
return console.warn(chalk.yellow(formatted)); | ||
case DiagnosticCategory.Error: | ||
throw new Error(chalk.red(formatted)); | ||
export function printDiagnostics(diagnostics, formatHost) { | ||
// Take all errors | ||
const [firstError, ...otherErrors] = diagnostics.filter(diagnostic => diagnostic.category === DiagnosticCategory.Error); | ||
// Take everything else | ||
const rest = [...otherErrors, ...diagnostics.filter(diagnostic => diagnostic.category !== DiagnosticCategory.Error)]; | ||
// Walk through all diagnostics that isn't errors | ||
for (const diagnostic of rest) { | ||
const formatted = formatDiagnostic(diagnostic, formatHost); | ||
switch (diagnostic.category) { | ||
case DiagnosticCategory.Message: | ||
return console.info(chalk.white(formatted)); | ||
case DiagnosticCategory.Warning: | ||
return console.warn(chalk.yellow(formatted)); | ||
case DiagnosticCategory.Error: | ||
return console.warn(chalk.red(formatted)); | ||
} | ||
} | ||
// Format and throw the first error, if there is any | ||
if (firstError != null) { | ||
throw new Error(chalk.red(formatDiagnostic(firstError, formatHost))); | ||
} | ||
} | ||
//# sourceMappingURL=helpers.js.map |
@@ -7,5 +7,5 @@ // tslint:disable:no-any | ||
import { TypescriptLanguageServiceEmitResultKind } from "./i-typescript-language-service-emit-result"; | ||
import { DECLARATION_EXTENSION, TSLIB } from "./constants"; | ||
import { DECLARATION_EXTENSION, TSLIB, TYPESCRIPT_EXTENSION } from "./constants"; | ||
import { TypescriptLanguageServiceHost } from "./typescript-language-service-host"; | ||
import { ensureRelative, getForcedCompilerOptions, printDiagnostic, resolveTypescriptOptions, toTypescriptDeclarationFileExtension } from "./helpers"; | ||
import { ensureRelative, getForcedCompilerOptions, printDiagnostics, resolveTypescriptOptions, toTypescriptDeclarationFileExtension } from "./helpers"; | ||
import { FormatHost } from "./format-host"; | ||
@@ -63,5 +63,3 @@ /** | ||
if (formatHost != null) { | ||
for (const diagnostic of languageServiceHost.getAllDiagnostics()) { | ||
printDiagnostic(diagnostic, formatHost); | ||
} | ||
printDiagnostics(languageServiceHost.getAllDiagnostics(), formatHost); | ||
} | ||
@@ -94,3 +92,3 @@ // Do no more if the compiler options are somehow not defined | ||
// Assert that the file passes the filter | ||
if (!filter(file)) { | ||
if (!filter(file) || !file.endsWith(TYPESCRIPT_EXTENSION)) { | ||
return undefined; | ||
@@ -97,0 +95,0 @@ } |
{ | ||
"name": "@wessberg/rollup-plugin-ts", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A Rollup plugin for Typescript", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89809
1569