node-aurora
Version:
Provides an interface to the Aurora Dreamband.
28 lines (16 loc) • 716 B
JavaScript
;
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _nodeFetch = require('node-fetch');
var _nodeFetch2 = _interopRequireDefault(_nodeFetch);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = function (srcPath, destPath) {
var _this = this;
var rename = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (srcPath.match(/https?:\/\//i)) {
return (0, _nodeFetch2.default)(srcPath).then(function (res) {
return _this.writeFile(destPath, res.body, rename);
});
}
return this.writeFile(destPath, _fs2.default.createReadStream(srcPath));
};