aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-08-16 09:59:58 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-09-07 20:03:50 +0300
commit10fdad742a2a6aa9f0e00b3e04fc5264797c53c7 (patch)
tree6b6d7b1375ff88f4bebbfa0703f7b595eb485df9 /build
parent7aa46e0df8a673e6b00550bbbbed21eed50108b7 (diff)
downloadjquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.tar.gz
jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.zip
Build: Update jscs and lint files
Fixes gh-2056
Diffstat (limited to 'build')
-rw-r--r--build/release.js7
-rw-r--r--build/release/cdn.js19
-rw-r--r--build/release/dist.js13
-rw-r--r--build/release/ensure-sizzle.js11
-rw-r--r--build/release/release-notes.js34
-rw-r--r--build/tasks/build.js51
-rw-r--r--build/tasks/dist.js14
-rw-r--r--build/tasks/install_jsdom.js2
-rw-r--r--build/tasks/sourcemap.js3
-rw-r--r--build/tasks/testswarm.js13
10 files changed, 98 insertions, 69 deletions
diff --git a/build/release.js b/build/release.js
index 231e2c4c3..7fd00bd8c 100644
--- a/build/release.js
+++ b/build/release.js
@@ -9,7 +9,7 @@ module.exports = function( Release ) {
npmTags = Release.npmTags;
- Release.define({
+ Release.define( {
npmPublish: true,
issueTracker: "github",
/**
@@ -36,6 +36,7 @@ module.exports = function( Release ) {
* for publishing the distribution repo instead
*/
npmTags: function() {
+
// origRepo is not defined if dist was skipped
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
return npmTags();
@@ -47,9 +48,9 @@ module.exports = function( Release ) {
dist: function( callback ) {
cdn.makeArchives( Release, function() {
dist( Release, callback );
- });
+ } );
}
- });
+ } );
};
module.exports.dependencies = [
diff --git a/build/release/cdn.js b/build/release/cdn.js
index 6c497ee0b..07285a56d 100644
--- a/build/release/cdn.js
+++ b/build/release/cdn.js
@@ -29,13 +29,14 @@ var
function makeReleaseCopies( Release ) {
shell.mkdir( "-p", cdnFolder );
- Object.keys( releaseFiles ).forEach(function( key ) {
+ Object.keys( releaseFiles ).forEach( function( key ) {
var text,
builtFile = releaseFiles[ key ],
unpathedFile = key.replace( /VER/g, Release.newVersion ),
releaseFile = cdnFolder + "/" + unpathedFile;
if ( /\.map$/.test( releaseFile ) ) {
+
// Map files need to reference the new uncompressed name;
// assume that all files reside in the same directory.
// "file":"jquery.min.js","sources":["jquery.js"]
@@ -47,7 +48,7 @@ function makeReleaseCopies( Release ) {
} else if ( builtFile !== releaseFile ) {
shell.cp( "-f", builtFile, releaseFile );
}
- });
+ } );
}
function makeArchives( Release, callback ) {
@@ -75,23 +76,23 @@ function makeArchives( Release, callback ) {
output.on( "error", function( err ) {
throw err;
- });
+ } );
archiver.pipe( output );
- files = files.map(function( item ) {
+ files = files.map( function( item ) {
return "dist" + ( rver.test( item ) ? "/cdn" : "" ) + "/" +
item.replace( rver, Release.newVersion );
- });
+ } );
sum = Release.exec( "md5sum " + files.join( " " ), "Error retrieving md5sum" );
fs.writeFileSync( md5file, sum );
files.push( md5file );
- files.forEach(function( file ) {
+ files.forEach( function( file ) {
archiver.append( fs.createReadStream( file ),
{ name: path.basename( file ) } );
- });
+ } );
archiver.finalize();
}
@@ -104,9 +105,9 @@ function makeArchives( Release, callback ) {
makeArchive( "mscdn", msFilesCDN, callback );
}
- buildGoogleCDN(function() {
+ buildGoogleCDN( function() {
buildMicrosoftCDN( callback );
- });
+ } );
}
module.exports = {
diff --git a/build/release/dist.js b/build/release/dist.js
index 8ef6faf86..32053eafb 100644
--- a/build/release/dist.js
+++ b/build/release/dist.js
@@ -5,6 +5,7 @@ module.exports = function( Release, complete ) {
shell = require( "shelljs" ),
pkg = require( Release.dir.repo + "/package.json" ),
distRemote = Release.remote.replace( "jquery.git", "jquery-dist.git" ),
+
// These files are included with the distribution
files = [
"src",
@@ -34,7 +35,7 @@ module.exports = function( Release, complete ) {
* Generate bower file for jquery-dist
*/
function generateBower() {
- return JSON.stringify({
+ return JSON.stringify( {
name: pkg.name,
main: pkg.main,
license: "MIT",
@@ -42,7 +43,7 @@ module.exports = function( Release, complete ) {
"package.json"
],
keywords: pkg.keywords
- }, null, 2);
+ }, null, 2 );
}
/**
@@ -57,14 +58,14 @@ module.exports = function( Release, complete ) {
"dist/jquery.js",
"dist/jquery.min.js",
"dist/jquery.min.map"
- ].forEach(function( file ) {
+ ].forEach( function( file ) {
shell.cp( Release.dir.repo + "/" + file, distFolder );
- });
+ } );
// Copy other files
- files.forEach(function( file ) {
+ files.forEach( function( file ) {
shell.cp( "-r", Release.dir.repo + "/" + file, Release.dir.dist );
- });
+ } );
// Write generated bower file
fs.writeFileSync( Release.dir.dist + "/bower.json", generateBower() );
diff --git a/build/release/ensure-sizzle.js b/build/release/ensure-sizzle.js
index c3e4ed159..795760643 100644
--- a/build/release/ensure-sizzle.js
+++ b/build/release/ensure-sizzle.js
@@ -8,7 +8,7 @@ var fs = require( "fs" ),
* @param {Function(string)} callback
*/
function getLatestSizzle( callback ) {
- npm.load(function( err, npm ) {
+ npm.load( function( err, npm ) {
if ( err ) {
throw err;
}
@@ -17,8 +17,8 @@ function getLatestSizzle( callback ) {
throw err;
}
callback( Object.keys( info )[ 0 ] );
- });
- });
+ } );
+ } );
}
/**
@@ -29,11 +29,12 @@ function getLatestSizzle( callback ) {
function ensureSizzle( Release, callback ) {
console.log();
console.log( "Checking Sizzle version..." );
- getLatestSizzle(function( latest ) {
+ getLatestSizzle( function( latest ) {
var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ),
version = match ? match[ 1 ] : "Not Found";
if ( version !== latest ) {
+
// colors is inherited from jquery-release
console.log(
"The Sizzle version in the src folder (" + version.red +
@@ -44,7 +45,7 @@ function ensureSizzle( Release, callback ) {
console.log( "Sizzle is latest (" + latest.green + ")" );
callback();
}
- });
+ } );
}
module.exports = ensureSizzle;
diff --git a/build/release/release-notes.js b/build/release/release-notes.js
index 00cdc8659..f3f6a6ff2 100644
--- a/build/release/release-notes.js
+++ b/build/release/release-notes.js
@@ -3,16 +3,16 @@
* jQuery Release Note Generator
*/
-var http = require("http"),
+var http = require( "http" ),
extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g,
- version = process.argv[2];
+ version = process.argv[ 2 ];
if ( !/^\d+\.\d+/.test( version ) ) {
console.error( "Invalid version number: " + version );
process.exit( 1 );
}
-http.request({
+http.request( {
host: "bugs.jquery.com",
port: 80,
method: "GET",
@@ -23,34 +23,36 @@ http.request({
res.on( "data", function( chunk ) {
data.push( chunk );
- });
+ } );
res.on( "end", function() {
var match, cur, cat,
- file = data.join("");
+ file = data.join( "" );
- while ( (match = extract.exec( file )) ) {
- if ( "#" + match[1] !== match[2] ) {
- cat = match[3];
+ while ( ( match = extract.exec( file ) ) ) {
+ if ( "#" + match[ 1 ] !== match[ 2 ] ) {
+ cat = match[ 3 ];
if ( !cur || cur !== cat ) {
if ( cur ) {
- console.log("</ul>");
+ console.log( "</ul>" );
}
cur = cat;
- console.log( "<h3>" + cat.charAt(0).toUpperCase() + cat.slice(1) + "</h3>" );
- console.log("<ul>");
+ console.log(
+ "<h3>" + cat.charAt( 0 ).toUpperCase() + cat.slice( 1 ) + "</h3>"
+ );
+ console.log( "<ul>" );
}
console.log(
- " <li><a href=\"http://bugs.jquery.com/ticket/" + match[1] + "\">#" +
- match[1] + ": " + match[2] + "</a></li>"
+ " <li><a href=\"http://bugs.jquery.com/ticket/" + match[ 1 ] + "\">#" +
+ match[ 1 ] + ": " + match[ 2 ] + "</a></li>"
);
}
}
if ( cur ) {
- console.log("</ul>");
+ console.log( "</ul>" );
}
- });
-}).end();
+ } );
+} ).end();
diff --git a/build/tasks/build.js b/build/tasks/build.js
index ead3deb19..750bac5b7 100644
--- a/build/tasks/build.js
+++ b/build/tasks/build.js
@@ -16,12 +16,16 @@ module.exports = function( grunt ) {
baseUrl: "src",
name: "jquery",
out: "dist/jquery.js",
+
// We have multiple minify steps
optimize: "none",
+
// Include dependencies loaded with require
findNestedDependencies: true,
+
// Avoid inserting define() placeholder
skipModuleInsertion: true,
+
// Avoid breaking semicolons inserted by r.js
skipSemiColonInsertion: true,
wrap: {
@@ -47,15 +51,17 @@ module.exports = function( grunt ) {
*/
function convert( name, path, contents ) {
var amdName;
+
// Convert var modules
if ( /.\/var\//.test( path ) ) {
contents = contents
- .replace( /define\([\w\W]*?return/, "var " + (/var\/([\w-]+)/.exec(name)[1]) + " =" )
+ .replace( /define\([\w\W]*?return/, "var " + ( /var\/([\w-]+)/.exec( name )[ 1 ] ) + " =" )
.replace( rdefineEnd, "" );
// Sizzle treatment
} else if ( /^sizzle$/.test( name ) ) {
contents = "var Sizzle =\n" + contents
+
// Remove EXPOSE lines from Sizzle
.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );
@@ -63,6 +69,7 @@ module.exports = function( grunt ) {
contents = contents
.replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" )
+
// Multiple exports
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
@@ -82,13 +89,15 @@ module.exports = function( grunt ) {
contents = contents
.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
}
+
// AMD Name
- if ( (amdName = grunt.option( "amd" )) != null && /^exports\/amd$/.test( name ) ) {
- if (amdName) {
+ if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
+ if ( amdName ) {
grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
} else {
grunt.log.writeln( "AMD name now anonymous" );
}
+
// Remove the comma for anonymous defines
contents = contents
.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );
@@ -121,7 +130,8 @@ module.exports = function( grunt ) {
excludeList = function( list, prepend ) {
if ( list ) {
prepend = prepend ? prepend + "/" : "";
- list.forEach(function( module ) {
+ list.forEach( function( module ) {
+
// Exclude var modules as well
if ( module === "var" ) {
excludeList(
@@ -130,20 +140,22 @@ module.exports = function( grunt ) {
return;
}
if ( prepend ) {
+
// Skip if this is not a js file and we're walking files in a dir
- if ( !(module = /([\w-\/]+)\.js$/.exec( module )) ) {
+ if ( !( module = /([\w-\/]+)\.js$/.exec( module ) ) ) {
return;
}
+
// Prepend folder name if passed
// Remove .js extension
- module = prepend + module[1];
+ module = prepend + module[ 1 ];
}
// Avoid infinite recursion
if ( excluded.indexOf( module ) === -1 ) {
excluder( "-" + module );
}
- });
+ } );
}
},
/**
@@ -158,12 +170,15 @@ module.exports = function( grunt ) {
module = m[ 2 ];
if ( exclude ) {
+
// Can't exclude certain modules
if ( minimum.indexOf( module ) === -1 ) {
+
// Add to excluded
if ( excluded.indexOf( module ) === -1 ) {
grunt.log.writeln( flag );
excluded.push( module );
+
// Exclude all files in the folder of the same name
// These are the removable dependencies
// It's fine if the directory is not there
@@ -173,10 +188,11 @@ module.exports = function( grunt ) {
grunt.verbose.writeln( e );
}
}
+
// Check removeWith list
excludeList( removeWith[ module ] );
} else {
- grunt.log.error( "Module \"" + module + "\" is a minimum requirement.");
+ grunt.log.error( "Module \"" + module + "\" is a minimum requirement." );
if ( module === "selector" ) {
grunt.log.error(
"If you meant to replace Sizzle, use -sizzle instead."
@@ -215,13 +231,13 @@ module.exports = function( grunt ) {
// Handle Sizzle exclusion
// Replace with selector-native
- if ( (index = excluded.indexOf( "sizzle" )) > -1 ) {
+ if ( ( index = excluded.indexOf( "sizzle" ) ) > -1 ) {
config.rawText.selector = "define(['./selector-native']);";
excluded.splice( index, 1 );
}
// Replace exports/global with a noop noConflict
- if ( (index = excluded.indexOf( "exports/global" )) > -1 ) {
+ if ( ( index = excluded.indexOf( "exports/global" ) ) > -1 ) {
config.rawText[ "exports/global" ] = "define(['../core']," +
"function( jQuery ) {\njQuery.noConflict = function() {};\n});";
excluded.splice( index, 1 );
@@ -233,9 +249,11 @@ module.exports = function( grunt ) {
// append excluded modules to version
if ( excluded.length ) {
version += " -" + excluded.join( ",-" );
+
// set pkg.version to version with excludes, so minified file picks it up
grunt.config.set( "pkg.version", version );
grunt.verbose.writeln( "Version changed to " + version );
+
// Have to use shallow or core will get excluded since it is a dependency
config.excludeShallow = excluded;
}
@@ -247,8 +265,10 @@ module.exports = function( grunt ) {
*/
config.out = function( compiled ) {
compiled = compiled
+
// Embed Version
.replace( /@VERSION/g, version )
+
// Embed Date
// yyyy-mm-ddThh:mmZ
.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
@@ -259,9 +279,10 @@ module.exports = function( grunt ) {
// Turn off opt-in if necessary
if ( !optIn ) {
+
// Overwrite the default inclusions with the explicit ones provided
config.rawText.jquery = "define([" +
- (included.length ? included.join(",") : "") +
+ ( included.length ? included.join( "," ) : "" ) +
"]);";
}
@@ -272,8 +293,8 @@ module.exports = function( grunt ) {
done();
}, function( err ) {
done( err );
- });
- });
+ } );
+ } );
// Special "alias" task to make custom build creation less grawlix-y
// Translation example
@@ -289,6 +310,6 @@ module.exports = function( grunt ) {
grunt.log.writeln( "Creating custom build...\n" );
- grunt.task.run([ "build:*:*" + (modules ? ":" + modules : ""), "uglify", "dist" ]);
- });
+ grunt.task.run( [ "build:*:*" + ( modules ? ":" + modules : "" ), "uglify", "dist" ] );
+ } );
};
diff --git a/build/tasks/dist.js b/build/tasks/dist.js
index 13e56336a..78ce2f254 100644
--- a/build/tasks/dist.js
+++ b/build/tasks/dist.js
@@ -21,14 +21,14 @@ module.exports = function( grunt ) {
flags = Object.keys( this.flags );
// Combine all output target paths
- paths = [].concat( stored, flags ).filter(function( path ) {
+ paths = [].concat( stored, flags ).filter( function( path ) {
return path !== "*";
- });
+ } );
// Ensure the dist files are pure ASCII
nonascii = false;
- distpaths.forEach(function( filename ) {
+ distpaths.forEach( function( filename ) {
var i, c,
text = fs.readFileSync( filename, "utf8" );
@@ -53,7 +53,7 @@ module.exports = function( grunt ) {
}
// Optionally copy dist files to other locations
- paths.forEach(function( path ) {
+ paths.forEach( function( path ) {
var created;
if ( !/\/$/.test( path ) ) {
@@ -63,9 +63,9 @@ module.exports = function( grunt ) {
created = path + filename.replace( "dist/", "" );
grunt.file.write( created, text );
grunt.log.writeln( "File '" + created + "' created." );
- });
- });
+ } );
+ } );
return !nonascii;
- });
+ } );
};
diff --git a/build/tasks/install_jsdom.js b/build/tasks/install_jsdom.js
index 21d67eb0e..73142b654 100644
--- a/build/tasks/install_jsdom.js
+++ b/build/tasks/install_jsdom.js
@@ -23,5 +23,5 @@ module.exports = function( grunt ) {
args: [ "install", "jsdom@" + version ],
opts: { stdio: "inherit" }
}, this.async() );
- });
+ } );
};
diff --git a/build/tasks/sourcemap.js b/build/tasks/sourcemap.js
index 5f4d5232f..3e4144de0 100644
--- a/build/tasks/sourcemap.js
+++ b/build/tasks/sourcemap.js
@@ -3,11 +3,12 @@ var fs = require( "fs" );
module.exports = function( grunt ) {
var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ];
grunt.registerTask( "remove_map_comment", function() {
+
// Remove the source map comment; it causes way too many problems.
// The map file is still generated for manual associations
// https://github.com/jquery/jquery/issues/1707
var text = fs.readFileSync( minLoc, "utf8" )
.replace( /\/\/# sourceMappingURL=\S+/, "" );
fs.writeFileSync( minLoc, text );
- });
+ } );
};
diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js
index 473bc9e72..902b33428 100644
--- a/build/tasks/testswarm.js
+++ b/build/tasks/testswarm.js
@@ -14,11 +14,12 @@ module.exports = function( grunt ) {
config = grunt.file.readJSON( configFile )[ projectName ];
browserSets = browserSets || config.browserSets;
if ( browserSets[ 0 ] === "[" ) {
+
// We got an array, parse it
browserSets = JSON.parse( browserSets );
}
timeout = timeout || 1000 * 60 * 15;
- tests = grunt.config([ this.name, "tests" ]);
+ tests = grunt.config( [ this.name, "tests" ] );
if ( pull ) {
jobName = "Pull <a href='https://github.com/jquery/jquery/pull/" +
@@ -28,18 +29,18 @@ module.exports = function( grunt ) {
commit + "'>" + commit.substr( 0, 10 ) + "</a>";
}
- tests.forEach(function( test ) {
+ tests.forEach( function( test ) {
runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test;
- });
+ } );
- testswarm.createClient({
+ testswarm.createClient( {
url: config.swarmUrl
} )
.addReporter( testswarm.reporters.cli )
.auth( {
id: config.authUsername,
token: config.authToken
- })
+ } )
.addjob(
{
name: jobName,
@@ -54,5 +55,5 @@ module.exports = function( grunt ) {
done( passed );
}
);
- });
+ } );
};