Make lint warn if Carriage Returns are present instead of throwing.
This commit is contained in:
		
							parent
							
								
									b13798f16c
								
							
						
					
					
						commit
						83eb405f2f
					
				
							
								
								
									
										30
									
								
								make.js
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								make.js
									
									
									
									
									
								
							@ -30,13 +30,29 @@ var DEFINES = {
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
// Helper functions
 | 
					// Helper functions
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
function throwIfCarriageReturnIsPresent(string) {
 | 
					function checkIfCarriageReturnsArePresent(string, throwOnError) {
 | 
				
			||||||
  if (string.match(/.*\r.*/)) {
 | 
					  if (string.match(/.*\r.*/)) {
 | 
				
			||||||
    throw('Carriage Return\'s should not be present. Please remove them.\n' +
 | 
					    var errorMessage =
 | 
				
			||||||
          'Also check your setting for: git config core.autocrlf');
 | 
					      '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
 | 
					// make all
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
@ -229,7 +245,7 @@ target.bundle = function() {
 | 
				
			|||||||
        {silent: true}).output.replace('\n', '');
 | 
					        {silent: true}).output.replace('\n', '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Handle only src/*.js for now.
 | 
					  // 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
 | 
					  // This just preprocesses the empty pdf.js file, we don't actually want to
 | 
				
			||||||
  // preprocess everything yet since other build targets use this file.
 | 
					  // preprocess everything yet since other build targets use this file.
 | 
				
			||||||
@ -692,10 +708,10 @@ target.lint = function() {
 | 
				
			|||||||
                    'extensions/firefox/components/*.js',
 | 
					                    'extensions/firefox/components/*.js',
 | 
				
			||||||
                    'extensions/chrome/*.js'];
 | 
					                    'extensions/chrome/*.js'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Handle only src/*.js for now.
 | 
					 | 
				
			||||||
  throwIfCarriageReturnIsPresent(cat('src/*.js'));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  exec('gjslint --nojsdoc ' + LINT_FILES.join(' '));
 | 
					  exec('gjslint --nojsdoc ' + LINT_FILES.join(' '));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Handle only src/*.js for now.
 | 
				
			||||||
 | 
					  warnIfCarriageReturnsArePresent(cat('src/*.js'));
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user