comparison node_modules/jQuery/grunt.js @ 77:cd921abc8887

added puredata trigger/OSC router
author Rob Canning <rob@foo.net>
date Tue, 15 Jul 2014 17:48:07 +0100
parents
children
comparison
equal deleted inserted replaced
76:0ae87af84e2f 77:cd921abc8887
1 module.exports = function(grunt) {
2
3 var exec = require('child_process').exec,
4 http = require('http'),
5 fs = require('fs'),
6 host = 'ajax.googleapis.com',
7 jqPath = '/ajax/libs/jquery/1.7.2/jquery.js';
8
9 grunt.registerTask('build', 'builds query module for us in nodje', function() {
10 var tmpDir = './tmp', distDir = './lib',
11 done = this.async(), wrapper;
12
13
14 function buildjQuery(jq) {
15 wrapper = fs.readFileSync('./src/wrapper.js', 'utf8');
16 wrapper = wrapper.replace('//JQUERY_SOURCE', jq);
17 fs.writeFileSync('./lib/node-jquery.js', wrapper);
18 done();
19 }
20
21 function writejQuery() {
22 var data = '',
23 req = http.request({
24 host: host,
25 port: 80,
26 path: jqPath,
27 method: 'GET'
28 }, function(res) {
29 res.setEncoding('utf8');
30 res.on('data', function(chunk) {
31 data += chunk;
32 });
33 res.on('end', function() {
34 fs.writeFileSync(tmpDir+'/jquery.js', data);
35 buildjQuery(data);
36 });
37 });
38 req.write('data\n');
39 req.write('data\n');
40 req.end();
41
42 }
43
44 function getjQuery() {
45 var jq = null;
46 try {
47 jq = fs.readFileSync(tmpDir+'/jquery.js', 'utf8');
48 buildjQuery(jq);
49 } catch (e) {
50 writejQuery();
51 }
52 }
53
54 exec('mkdir '+tmpDir+' && mkdir '+distDir, getjQuery);
55 });
56
57 grunt.registerTask('clean', 'removes dist and tmp directories', function() {
58 var done = this.async();
59 exec('rm -rf ./tmp && rm -rf ./lib', function() {
60 done();
61 });
62 });
63
64 // Project configuration.
65 grunt.initConfig({
66 pkg: '<json:package.json>',
67 test: {
68 files: ['test/*.js']
69 },
70 lint: {
71 files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
72 },
73 watch: {
74 files: '<config:lint.files>',
75 tasks: 'default'
76 },
77 jshint: {
78 options: {
79 curly: true,
80 eqeqeq: true,
81 immed: true,
82 latedef: true,
83 newcap: true,
84 noarg: true,
85 sub: true,
86 undef: true,
87 boss: true,
88 eqnull: true,
89 node: true
90 },
91 globals: {
92 exports: true
93 }
94 }
95 });
96
97 // Default task.
98 grunt.registerTask('default', 'build test');
99
100 };