-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathGruntfile.js
80 lines (66 loc) · 1.79 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var async = require( "async" );
module.exports = function( grunt ) {
grunt.loadNpmTasks( "grunt-jquery-content" );
grunt.initConfig({
"build-posts": {
page: "pages/**"
},
"build-resources": {
all: "resources/**"
},
wordpress: (function() {
var config = require( "./config" );
config.dir = "dist/wordpress";
return config;
})()
});
grunt.registerTask( "build-member-list", function() {
var https = require( "https" ),
done = this.async(),
path = grunt.config( "wordpress.dir" ) + "/resources/corporate-members.json";
function getMembers( level, callback ) {
var request = https.request({
host: "raw.githubusercontent.com",
path: "/jquery/jquery.org/master/data/members/" + level + ".json"
}, function ( response ) {
var json = "";
response.setEncoding( "utf8" );
response.on( "data", function( chunk ) {
json += chunk;
});
response.on( "end", function() {
try {
json = JSON.parse( json );
} catch( error ) {
return callback( error );
}
callback( null, json );
});
});
request.end();
}
async.parallel({
founding: getMembers.bind( null, "founding" ),
platinum: getMembers.bind( null, "platinum" ),
gold: getMembers.bind( null, "gold" )
}, function( error, members ) {
if ( error ) {
return done( error );
}
var corporateMembers = members.founding
.concat( members.platinum )
.concat( members.gold )
.filter(function( member ) {
// modern.IE has a special membership which doesn't get logo rotation
if ( member.name === "modern.IE" ) {
return false;
}
return true;
});
corporateMembers = JSON.stringify( corporateMembers );
grunt.file.write( path, corporateMembers );
done();
});
});
grunt.registerTask( "build", [ "build-posts", "build-resources", "build-member-list" ] );
};