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.
This commit is contained in:
Kalervo Kujala 2012-08-18 23:01:01 +03:00
parent d38781d72e
commit b13798f16c

33
make.js
View File

@ -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);
};