Skip to content

Commit

Permalink
Build: Skip running ESLint on Node.js 0.x
Browse files Browse the repository at this point in the history
ESLint 3.0 drops support for Node.js older than 4.x. To be able to update
to this version and yet not block our contributors from building jQuery
on older Node.js (at least until it's supported by upstream) this commit
makes ESLint skipped on older Node; a proper message is displayed then.

Fixes gh-3222
  • Loading branch information
mgol committed Jul 13, 2016
1 parent 6e605af commit 030191a
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions Gruntfile.js
Expand Up @@ -14,9 +14,14 @@ module.exports = function( grunt ) {


var fs = require( "fs" ), var fs = require( "fs" ),
gzip = require( "gzip-js" ), gzip = require( "gzip-js" ),
oldNode = /^v0\./.test( process.version );


// Skip jsdom-related tests in Node.js 0.10 & 0.12 // Support: Node.js <4
runJsdomTests = !/^v0/.test( process.version ); // Skip running tasks that dropped support for Node.js 0.10 & 0.12
// in those Node versions.
function runIfNewNode( task ) {
return oldNode ? "print_old_node_message:" + task : task;
}


if ( !grunt.option( "filename" ) ) { if ( !grunt.option( "filename" ) ) {
grunt.option( "filename", "jquery.js" ); grunt.option( "filename", "jquery.js" );
Expand Down Expand Up @@ -176,33 +181,50 @@ module.exports = function( grunt ) {
} ); } );


// Load grunt tasks from NPM packages // Load grunt tasks from NPM packages
require( "load-grunt-tasks" )( grunt ); // Support: Node.js <4
// Don't load the eslint task in old Node.js, it won't parse.
require( "load-grunt-tasks" )( grunt, {
pattern: oldNode ? [ "grunt-*", "!grunt-eslint" ] : [ "grunt-*" ]
} );


// Integrate jQuery specific tasks // Integrate jQuery specific tasks
grunt.loadTasks( "build/tasks" ); grunt.loadTasks( "build/tasks" );


grunt.registerTask( "lint", [ "jsonlint", "eslint:all" ] ); grunt.registerTask( "print_old_node_message", function() {
var task = [].slice.call( arguments ).join( ":" );
grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
} );


// Don't run Node-related tests in Node.js < 1.0.0 as they require an old grunt.registerTask( "lint", [
// jsdom version that needs compiling, making it harder for people to compile "jsonlint",
// jQuery on Windows. (see gh-2519) runIfNewNode( "eslint:all" )
grunt.registerTask( "test_fast", runJsdomTests ? [ "node_smoke_tests" ] : [] ); ] );

grunt.registerTask( "test_fast", [ runIfNewNode( "node_smoke_tests" ) ] );


grunt.registerTask( "test", [ "test_fast" ].concat( grunt.registerTask( "test", [ "test_fast" ].concat(
runJsdomTests ? [ "promises_aplus_tests" ] : [] [ runIfNewNode( "promises_aplus_tests" ) ]
) ); ) );


// Short list as a high frequency watch task // Short list as a high frequency watch task
grunt.registerTask( "dev", [ grunt.registerTask( "dev", [
"build:*:*", "build:*:*",
"newer:eslint:dev", runIfNewNode( "newer:eslint:dev" ),
"uglify", "uglify",
"remove_map_comment", "remove_map_comment",
"dist:*" "dist:*"
] ]
); );


grunt.registerTask( "default", [ "dev", "eslint:dist", "test_fast", "compare_size" ] ); grunt.registerTask( "default", [

"dev",
grunt.registerTask( "precommit_lint", [ "newer:jsonlint", "newer:eslint:all" ] ); runIfNewNode( "eslint:dist" ),
"test_fast",
"compare_size"
] );

grunt.registerTask( "precommit_lint", [
"newer:jsonlint",
runIfNewNode( "newer:eslint:all" )
] );
}; };

1 comment on commit 030191a

@mgol
Copy link
Member Author

@mgol mgol commented on 030191a Jul 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was PR #3225, I forgot to link the commit.

Please sign in to comment.