From b13798f16c28b033910a59a6183c0398f0d75480 Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sat, 18 Aug 2012 23:01:01 +0300 Subject: [PATCH] Add carriage return checks to make.js. The target.bundle and target.lint will throw if carriage return's are present in the files that are being processed. --- make.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/make.js b/make.js index 1d2e5cfcf..94d0dee19 100755 --- a/make.js +++ b/make.js @@ -27,6 +27,16 @@ var DEFINES = { CHROME: false }; +// +// Helper functions +// +function throwIfCarriageReturnIsPresent(string) { + 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'); + } +} + // // make all // @@ -218,6 +228,9 @@ target.bundle = function() { bundleVersion = exec('git log --format="%h" -n 1', {silent: true}).output.replace('\n', ''); + // Handle only src/*.js for now. + throwIfCarriageReturnIsPresent(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. builder.preprocess('pdf.js', ROOT_DIR + BUILD_TARGET, @@ -671,15 +684,18 @@ target.lint = function() { echo(); echo('### Linting JS files (this can take a while!)'); - var LINT_FILES = 'src/*.js \ - web/*.js \ - test/*.js \ - test/unit/*.js \ - extensions/firefox/*.js \ - extensions/firefox/components/*.js \ - extensions/chrome/*.js'; + var LINT_FILES = ['src/*.js', + 'web/*.js', + 'test/*.js', + 'test/unit/*.js', + 'extensions/firefox/*.js', + 'extensions/firefox/components/*.js', + 'extensions/chrome/*.js']; - exec('gjslint --nojsdoc ' + LINT_FILES); + // Handle only src/*.js for now. + throwIfCarriageReturnIsPresent(cat('src/*.js')); + + exec('gjslint --nojsdoc ' + LINT_FILES.join(' ')); }; // @@ -692,3 +708,4 @@ target.clean = function() { rm('-rf', BUILD_DIR); }; +