diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/node_modules/jQuery/grunt.js	Tue Jul 15 17:48:07 2014 +0100
@@ -0,0 +1,100 @@
+module.exports = function(grunt) {
+  
+  var exec = require('child_process').exec,
+      http = require('http'),
+      fs = require('fs'),
+      host = 'ajax.googleapis.com',
+      jqPath = '/ajax/libs/jquery/1.7.2/jquery.js';
+
+  grunt.registerTask('build', 'builds query module for us in nodje', function() {
+    var tmpDir = './tmp', distDir = './lib',
+        done = this.async(), wrapper;
+
+
+    function buildjQuery(jq) {
+      wrapper = fs.readFileSync('./src/wrapper.js', 'utf8');
+      wrapper = wrapper.replace('//JQUERY_SOURCE', jq);
+      fs.writeFileSync('./lib/node-jquery.js', wrapper);
+      done();
+    }
+
+    function writejQuery() {
+      var data = '',
+          req = http.request({
+        host: host,
+        port: 80, 
+        path: jqPath,
+        method: 'GET'
+      }, function(res) {
+        res.setEncoding('utf8');  
+        res.on('data', function(chunk) {
+          data += chunk;  
+        });
+        res.on('end', function() {
+          fs.writeFileSync(tmpDir+'/jquery.js', data);
+          buildjQuery(data);
+        });
+      });
+      req.write('data\n');
+      req.write('data\n');
+      req.end();
+
+    }
+
+    function getjQuery() {
+      var jq = null;
+      try {
+        jq = fs.readFileSync(tmpDir+'/jquery.js', 'utf8');  
+        buildjQuery(jq);
+      } catch (e) {
+        writejQuery();
+      }
+    }
+
+    exec('mkdir '+tmpDir+' && mkdir '+distDir, getjQuery);
+  });
+
+  grunt.registerTask('clean', 'removes dist and tmp directories', function() {
+    var done = this.async();
+    exec('rm -rf ./tmp && rm -rf ./lib', function() {
+      done();
+    });
+  });
+
+  // Project configuration.
+  grunt.initConfig({
+    pkg: '<json:package.json>',
+    test: {
+      files: ['test/*.js']
+    },
+    lint: {
+      files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
+    },
+    watch: {
+      files: '<config:lint.files>',
+      tasks: 'default'
+    },
+    jshint: {
+      options: {
+        curly: true,
+        eqeqeq: true,
+        immed: true,
+        latedef: true,
+        newcap: true,
+        noarg: true,
+        sub: true,
+        undef: true,
+        boss: true,
+        eqnull: true,
+        node: true
+      },
+      globals: {
+        exports: true
+      }
+    }
+  });
+
+  // Default task.
+  grunt.registerTask('default', 'build test');
+
+};