Commits

carkraus committed 4f11cf7

cool, task working

Comments (0)

Files changed (9)

     },
     glue: {
       icons: {
-        files: ['test/assets/*.png']
-      },
-      bgs: {
-        files: ['test/assets/*.png']
+        src: 'test/assets/icons',
+        // dest: 'test/assets/icons_out',
+        opts: '--css=test/assets/out --img=test/assets/out --less --namespace=ico --optipng'
       }
+      // ,
+      // bgs: {
+      //   files: ['test/assets/*.png']
+      // }
     },
     watch: {
       files: '<config:lint.files>',
  */
 
 module.exports = function(grunt) {
-  // var exec = require('child_process').exec;
+  var exec = require('child_process').exec;
 
   // ==========================================================================
   // TASKS
   // ==========================================================================
-  grunt.registerMultiTask('glue', 'Your task description goes here.', function() {
-    var cmd = ['glue'];
-    grunt.log.writeln(this.target + ': ' + this.data.files);
+  grunt.registerMultiTask('glue', 'Glue wrapper.', function() {
+    var done = this.async(),
+        config = this.data,
+        src = config.src,
+        dest = config.dest;
+        opts = config.opts
+    // var options = this.options({
+    //   separator: null,
+    //   banner: grunt.config('banner') || '',
+    //   uglify: {}
+    // });
 
-
-
-    // exec(cmd, function(err, stdout, stderr) {
-    //   if (err) throw err;
-    //   grunt.log.write(stdout);
-    // });
+    var cmd = 'glue';
+    cmd += ' ' + src;
+    if(dest) {
+      cmd += ' ' + dest;
+    }
+    if(opts) {
+      cmd += ' ' + opts;
+    }
+    grunt.log.debug(cmd);
+    exec(cmd, function(err, stdout, stderr) {
+      if (err) throw err;
+      if (stderr) {
+        return false;
+      }
+      done();
+    });
   });
 
   // ==========================================================================
   // HELPERS
   // ==========================================================================
-  grunt.registerHelper('glue', function() {
-    return 'glue';
+  grunt.registerHelper('glue', function(src, target, options) {
+    // grunt.log.writeln(src);
+    // grunt.log.writeln(target);
+    // grunt.log.writeln(options);
+    // grunt.log.writeln(grunt.toString());
+    // return 'glue ' + src;
   });
 
 };

test/assets/foo/drink.png

Removed
Old image

test/assets/foo/drink_empty.png

Removed
Old image

test/assets/foo/sport_soccer.png

Removed
Old image

test/assets/icons/drink.png

Added
New image

test/assets/icons/drink_empty.png

Added
New image

test/assets/icons/sport_soccer.png

Added
New image

test/glue_test.js

-var grunt = require('grunt');
+var grunt = require('grunt'),
+    rimraf = require('rimraf');
 
 /*
   ======== A Handy Little Nodeunit Reference ========
 
 exports['glue'] = {
   setUp: function(done) {
-    // setup here
+    // Sample dir
+    var sampleDir = '';
+    // Test output
+    var outDir = '/tmp/glueTestOut';
+    grunt.file.mkdir(outDir)
+    done();
+  },
+  tearDown: function(done) {
+    // Test output
+    var outDir = '/tmp/glueTestOut';
+    rimraf.sync(outDir);
     done();
   },
   'helper': function(test) {
-    test.expect(1);
     // tests here
-    test.equal(grunt.helper('glue'), 'glue', 'should return the correct value.');
+    test.equal(grunt.helper('glue', 'foo'), 'glue foo', 'should return the correct value.');
     test.done();
   }
 };