'use strict';
var fs = require('fs');
var path = require('path');

var async = require('async');
var cpr = require('cpr');
var cp = require('cp');


exports.copyExtraAssets = function(buildDir, assets, cb) {
  assets = assets || [];

  async.forEach(assets, function(asset, cb) {
    var from = asset.from;

    if(from.indexOf('./') === 0) {
        cp(from, path.join(buildDir, asset.to, from), cb);
    }
    else {
        cpr(from, path.join(buildDir, asset.to), cb);
    }
  }, cb);
};

exports.copyIfExists = function(from, to, cb) {
  fs.exists(from, function(exists) {
    if(exists) {
      cpr(from, to, cb);
    }
    else {
      cb();
    }
  });
};

'use strict';
var fs = require('fs');
var path = require('path');

var async = require('async');
var cpr = require('cpr');
var cp = require('cp');


exports.copyExtraAssets = function(buildDir, assets, cb) {
  assets = assets || [];

  async.forEach(assets, function(asset, cb) {
    var from = asset.from;
    var stats = fs.statSync(from);

    if(from.indexOf('./') === 0 && stats.isFile()) {
        cp(from, path.join(buildDir, asset.to, from), cb);
    }
    else {
        cpr(from, path.join(buildDir, asset.to), cb);
    }
  }, cb);
};

exports.copyIfExists = function(from, to, cb) {
  fs.exists(from, function(exists) {
    if(exists) {
      cpr(from, to, cb);
    }
    else {
      cb();
    }
  });
};

Check against dir when copying assets
Check against dir when copying assets

Now a declaration like

```javascript
{
  from: './extra',
  to: '.'
}
```

will work as expected. Previously `from` expected to find a file in this
case and failed as a result. This can be possibly cleaned up further.
