From 83eb405f2f9f2e20dab28d315233eb114143ba7b Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 19 Aug 2012 00:55:23 +0300 Subject: [PATCH] Make lint warn if Carriage Returns are present instead of throwing. --- make.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/make.js b/make.js index 94d0dee19..bc04e8530 100755 --- a/make.js +++ b/make.js @@ -30,13 +30,29 @@ var DEFINES = { // // Helper functions // -function throwIfCarriageReturnIsPresent(string) { +function checkIfCarriageReturnsArePresent(string, throwOnError) { if (string.match(/.*\r.*/)) { - throw('Carriage Return\'s should not be present. Please remove them.\n' + - 'Also check your setting for: git config core.autocrlf'); + var errorMessage = + 'Carriage Return\'s should not be present. Please remove them.\n' + + 'Also check your setting for: git config core.autocrlf.'; + + if (throwOnError) { + throw(errorMessage); + } else { + echo(); + echo(errorMessage); + } } } +function throwIfCarriageReturnsArePresent(string) { + checkIfCarriageReturnsArePresent(string, true); +} + +function warnIfCarriageReturnsArePresent(string) { + checkIfCarriageReturnsArePresent(string, false); +} + // // make all // @@ -229,7 +245,7 @@ target.bundle = function() { {silent: true}).output.replace('\n', ''); // Handle only src/*.js for now. - throwIfCarriageReturnIsPresent(cat('*.js')); + throwIfCarriageReturnsArePresent(cat('*.js')); // This just preprocesses the empty pdf.js file, we don't actually want to // preprocess everything yet since other build targets use this file. @@ -692,10 +708,10 @@ target.lint = function() { 'extensions/firefox/components/*.js', 'extensions/chrome/*.js']; - // Handle only src/*.js for now. - throwIfCarriageReturnIsPresent(cat('src/*.js')); - exec('gjslint --nojsdoc ' + LINT_FILES.join(' ')); + + // Handle only src/*.js for now. + warnIfCarriageReturnsArePresent(cat('src/*.js')); }; //