var sources = [
  'Gruntfile.js',
  'server.js',
  'src/**/*.js',
  'opt/**/*.js'
];

var js = sources.concat('test/**/*.js');

module.exports = function(grunt) {
  grunt.initConfig({
    simplemocha: {
      options: {
        timeout: 3000,
        globals: [
          'expect',
          'sinon'
        ],
        ignoreLeaks: false,
        ui: 'bdd',
        reporter: 'dot'
      },

      all: { src: ['test/**/*_spec.js'] }
    },

    jshint: {
      all: sources,
      options: {
        force: true
      }
    },

    watch: {
      scripts: {
        files: js,
        tasks: ['default']
      },
      pi: {
        options: { spawn: false },
        files: js,
        tasks: [/* transfers the file */]
      },
    }
  });

  grunt.event.on('watch', function(action, filepath, target) {
    if (target === 'pi') {
      var child = grunt.util.spawn({
        cmd: "scp",
        args: [
          filepath,
          'root@192.168.0.107:/opt/netpocketos/'+filepath
        ]
      }, function() {
        grunt.log.writeln("Transferred "+filepath);
      });
      child.stdout.pipe(process.stdout);
      child.stderr.pipe(process.stderr);
    }
  });

  grunt.registerTask('default', [
    'jshint',
    'simplemocha',
    'cover',
    'watch'
  ]);

  grunt.loadNpmTasks('grunt-simple-mocha');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('cover', function() {
    var done = this.async();
    var reportPath = '/coverage/lcov-report/index.html';
    var child = grunt.util.spawn({cmd: 'istanbul', args: ['cover', 'node_modules/mocha/bin/_mocha', 'test/**/*.js']}, function() {
      grunt.log.writeln('file://'+__dirname+reportPath);
      done();
    });
  });
};

@@ -1,12 +1,75 @@
+var piUserHost = %22root@192.168.0.107%22;%0Avar fs = require('fs');%0A
 var sources 
@@ -899,32 +899,188 @@
      var child =
+ null;%0A      remotePath = '/opt/netpocketos/'+filepath;%0A      if (fs.lstatSync(filepath).isDirectory()) %7B%0A        // Make directory remotely%0A        child =
  grunt.util.spaw
@@ -1095,20 +1095,24 @@
     
+  
 cmd: %22s
-cp
+sh
 %22,%0A
+  
     
@@ -1137,76 +1137,354 @@
     
-filepath,%0A          'root@192.168.0.107:/opt/netpocketos/'+filep
+  piUserHost,%0A            %22mkdir%22,%0A            remotePath%0A          %5D%0A        %7D, function() %7B%0A          grunt.log.writeln(%22Created folder %22+remotePath);%0A        %7D);%0A      %7D else %7B%0A        // Transfer the file%0A        child = grunt.util.spawn(%7B%0A          cmd: %22scp%22,%0A          args: %5B%0A            filepath,%0A            piUserHost+':'+remoteP
 ath%0A
+  
     
@@ -1491,24 +1491,26 @@
     %5D%0A      
+  
 %7D, function(
@@ -1505,32 +1505,34 @@
 %7D, function() %7B%0A
+  
         grunt.lo
@@ -1560,19 +1560,23 @@
 d %22+
-filep
+remoteP
 ath);%0A
+  
     
@@ -1577,24 +1577,32 @@
         %7D);%0A
+      %7D%0A
       child.

make folders on pi for me