Skip to content

Commit ace05a7

Browse files
committed
Merge pull request mozilla#1999 from kkujala/master
Add carriage return checks to make.js.
2 parents e11e811 + 288705d commit ace05a7

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

external/crlfchecker/crlfchecker.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
4+
function checkIfCrlfIsPresent(files) {
5+
var failed = [];
6+
7+
(ls(files)).forEach(function checkCrlf(file) {
8+
if ((cat(file)).match(/.*\r.*/)) {
9+
failed.push(file);
10+
}
11+
});
12+
13+
if (failed.length) {
14+
var errorMessage =
15+
'Please remove carriage return\'s from\n' + failed.join('\n') + '\n' +
16+
'Also check your setting for: git config core.autocrlf.';
17+
18+
echo();
19+
echo(errorMessage);
20+
exit(1);
21+
}
22+
}
23+
24+
exports.checkIfCrlfIsPresent = checkIfCrlfIsPresent;
25+

make.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22
require('./external/shelljs/make');
33
var builder = require('./external/builder/builder.js');
4+
var crlfchecker = require('./external/crlfchecker/crlfchecker.js');
45

56
var ROOT_DIR = __dirname + '/', // absolute path to project's root
67
BUILD_DIR = 'build/',
@@ -218,6 +219,8 @@ target.bundle = function() {
218219
bundleVersion = exec('git log --format="%h" -n 1',
219220
{silent: true}).output.replace('\n', '');
220221

222+
crlfchecker.checkIfCrlfIsPresent(SRC_FILES);
223+
221224
// This just preprocesses the empty pdf.js file, we don't actually want to
222225
// preprocess everything yet since other build targets use this file.
223226
builder.preprocess('pdf.js', ROOT_DIR + BUILD_TARGET,
@@ -673,15 +676,17 @@ target.lint = function() {
673676
echo();
674677
echo('### Linting JS files (this can take a while!)');
675678

676-
var LINT_FILES = 'src/*.js \
677-
web/*.js \
678-
test/*.js \
679-
test/unit/*.js \
680-
extensions/firefox/*.js \
681-
extensions/firefox/components/*.js \
682-
extensions/chrome/*.js';
679+
var LINT_FILES = ['src/*.js',
680+
'web/*.js',
681+
'test/*.js',
682+
'test/unit/*.js',
683+
'extensions/firefox/*.js',
684+
'extensions/firefox/components/*.js',
685+
'extensions/chrome/*.js'];
686+
687+
exec('gjslint --nojsdoc ' + LINT_FILES.join(' '));
683688

684-
exec('gjslint --nojsdoc ' + LINT_FILES);
689+
crlfchecker.checkIfCrlfIsPresent(LINT_FILES);
685690
};
686691

687692
//
@@ -694,3 +699,4 @@ target.clean = function() {
694699

695700
rm('-rf', BUILD_DIR);
696701
};
702+

0 commit comments

Comments
 (0)