Skip to content

Commit 8b2be8f

Browse files
author
nickpape-msft
committed
Add an additional build configuration which will treat warnings as if they are errors
1 parent 9e64fd0 commit 8b2be8f

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

common/npm-local/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"dependencies": {
3+
"npm": "3.10.8"
4+
},
5+
"description": "Temporary file generated by the NPMX tool",
6+
"name": "local-npm-install",
7+
"private": true,
8+
"version": "0.0.0"
9+
}

gulp-core-build/src/IBuildConfig.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export interface IBuildConfig {
4949
/** Build a full production build. */
5050
production?: boolean;
5151

52+
/** Show warnings as errors (write them in red vs yellow to stderr, and fail the build) */
53+
showWarningsAsErrors?: boolean;
54+
5255
/** Arguments passed in. */
5356
args?: { [name: string]: string | boolean };
5457

gulp-core-build/src/logging.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const prettyTime = require('pretty-hrtime');
88
/* tslint:enable:typedef */
99
import * as state from './State';
1010
import { getFlagValue } from './config';
11+
import { getConfig } from './index';
1112

1213
const WROTE_ERROR_KEY: string = '__gulpCoreBuildWroteError';
1314

@@ -54,7 +55,7 @@ let globalInstance: any = global as any;
5455
const localCache: ILocalCache = globalInstance.__loggingCache = globalInstance.__loggingCache || {
5556
warnings: [],
5657
errors: [],
57-
testsRun: 0,
58+
testsRun: 0,;
5859
subTasksRun: 0,
5960
testsPassed: 0,
6061
testsFailed: 0,
@@ -442,8 +443,13 @@ export function warn(...args: Array<string | Chalk.ChalkChain>): void {
442443
const stringMessage: string = args.join(' ');
443444

444445
if (!localCache.errorAndWarningSupressions[stringMessage]) {
445-
localCache.warnings.push(stringMessage);
446-
log(gutil.colors.yellow.apply(undefined, args));
446+
if (getConfig().showWarningsAsErrors) {
447+
localCache.errors.push(stringMessage);
448+
log(gutil.colors.red.apply(undefined, args));
449+
} else {
450+
localCache.warnings.push(stringMessage);
451+
log(gutil.colors.yellow.apply(undefined, args));
452+
}
447453
}
448454
}
449455

0 commit comments

Comments
 (0)