diff options
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/output.js b/lib/output.js index 5c28ca1..b787edc 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1,12 +1,11 @@ var _ = require('lodash'); -var fs = require('graceful-fs'); -var mkdirp = require('mkdirp'); var Ignore = require('ignore'); var path = require('path'); var Promise = require('./utils/promise'); var pathUtil = require('./utils/path'); var error = require('./utils/error'); +var fs = require('./utils/fs'); var generators = require('./generators'); var PluginsManager = require('./plugins'); @@ -44,15 +43,32 @@ Output.prototype.resolve = function(filename) { // Write a file/buffer to the output folder Output.prototype.writeFile = function(filename, buf) { - filename = this.resolve(filename); - var folder = path.dirname(filename); + var that = this; - // Ensure fodler exists - return Promise.nfcall(mkdirp, folder) + return Promise() + .then(function() { + filename = that.resolve(filename); + var folder = path.dirname(filename); + + // Ensure fodler exists + return fs.mkdirp(folder); + }) // Write the file .then(function() { - return Promise.nfcall(fs.writeFile, filename, buf); + return fs.writeFile(filename, buf); + }); +}; + +// Copy a file to the output +Output.prototype.copyFile = function(from, to) { + var that = this; + + return Promise() + .then(function() { + to = that.resolve(to); + + return fs.copy(from, to); }); }; @@ -74,7 +90,7 @@ Output.prototype.generate = function() { // Create the output folder .then(function() { - return Promise.nfcall(mkdirp, that.root()); + return fs.mkdirp(that.root()); }) // Initialize the generation |