1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Create crlfchecker module and use it in make.js.

Provide names of the files that contain crlf in the output.
Exit(1) is used instead of throw.
This commit is contained in:
Kalervo Kujala 2012-08-20 20:33:41 +03:00
parent 83eb405f2f
commit 2ffd3ae1c7
2 changed files with 28 additions and 28 deletions

31
make.js
View file

@ -1,6 +1,7 @@
#!/usr/bin/env node
require('./external/shelljs/make');
var builder = require('./external/builder/builder.js');
var crlfchecker = require('./external/crlfchecker/crlfchecker.js');
var ROOT_DIR = __dirname + '/', // absolute path to project's root
BUILD_DIR = 'build/',
@ -27,32 +28,6 @@ var DEFINES = {
CHROME: false
};
//
// Helper functions
//
function checkIfCarriageReturnsArePresent(string, throwOnError) {
if (string.match(/.*\r.*/)) {
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
//
@ -245,7 +220,7 @@ target.bundle = function() {
{silent: true}).output.replace('\n', '');
// Handle only src/*.js for now.
throwIfCarriageReturnsArePresent(cat('*.js'));
crlfchecker.checkIfCrlfIsPresent(['*.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.
@ -711,7 +686,7 @@ target.lint = function() {
exec('gjslint --nojsdoc ' + LINT_FILES.join(' '));
// Handle only src/*.js for now.
warnIfCarriageReturnsArePresent(cat('src/*.js'));
crlfchecker.checkIfCrlfIsPresent(['src/*.js']);
};
//