diff --git a/lib/dest/index.js b/lib/dest/index.js index 776d4a48..73acbd5a 100644 --- a/lib/dest/index.js +++ b/lib/dest/index.js @@ -18,11 +18,11 @@ function dest(outFolder, opt) { ['boolean', 'string', 'object'], opt.sourcemaps); function saveFile(file, enc, cb) { - prepareWrite(outFolder, file, opt, function(err, writePath) { + prepareWrite(outFolder, file, opt, function(err) { if (err) { return cb(err); } - writeContents(writePath, file, cb); + writeContents(file, cb); }); } diff --git a/lib/dest/write-contents/index.js b/lib/dest/write-contents/index.js index bc4fe720..6e513bde 100644 --- a/lib/dest/write-contents/index.js +++ b/lib/dest/write-contents/index.js @@ -5,25 +5,25 @@ var writeStream = require('./write-stream'); var writeBuffer = require('./write-buffer'); var writeSymbolicLink = require('./write-symbolic-link'); -function writeContents(writePath, file, callback) { +function writeContents(file, callback) { // If directory then mkdirp it if (file.isDirectory()) { - return writeDir(writePath, file, written); + return writeDir(file, written); } // Stream it to disk yo if (file.isStream()) { - return writeStream(writePath, file, written); + return writeStream(file, written); } // Write it as a symlink if (file.symlink) { - return writeSymbolicLink(writePath, file, written); + return writeSymbolicLink(file, written); } // Write it like normal if (file.isBuffer()) { - return writeBuffer(writePath, file, written); + return writeBuffer(file, written); } // If no contents then do nothing diff --git a/lib/dest/write-contents/write-buffer.js b/lib/dest/write-contents/write-buffer.js index 6f4bf256..54d3fb44 100644 --- a/lib/dest/write-contents/write-buffer.js +++ b/lib/dest/write-contents/write-buffer.js @@ -2,13 +2,13 @@ var fo = require('../../file-operations'); -function writeBuffer(writePath, file, written) { +function writeBuffer(file, written) { var opt = { mode: file.stat.mode, flag: file.flag, }; - fo.writeFile(writePath, file.contents, opt, onWriteFile); + fo.writeFile(file.path, file.contents, opt, onWriteFile); function onWriteFile(writeErr, fd) { if (writeErr) { diff --git a/lib/dest/write-contents/write-dir.js b/lib/dest/write-contents/write-dir.js index 70b187f7..b7d23019 100644 --- a/lib/dest/write-contents/write-dir.js +++ b/lib/dest/write-contents/write-dir.js @@ -5,19 +5,19 @@ var mkdirp = require('mkdirp'); var fo = require('../../file-operations'); -function writeDir(writePath, file, written) { +function writeDir(file, written) { var mkdirpOpts = { mode: file.stat.mode, fs: fs, }; - mkdirp(writePath, mkdirpOpts, onMkdirp); + mkdirp(file.path, mkdirpOpts, onMkdirp); function onMkdirp(mkdirpErr) { if (mkdirpErr) { return written(mkdirpErr); } - fs.open(writePath, 'r', onOpen); + fs.open(file.path, 'r', onOpen); } function onOpen(openErr, fd) { diff --git a/lib/dest/write-contents/write-stream.js b/lib/dest/write-contents/write-stream.js index c3c52fd1..8683bec7 100644 --- a/lib/dest/write-contents/write-stream.js +++ b/lib/dest/write-contents/write-stream.js @@ -5,13 +5,13 @@ var fs = require('graceful-fs'); var fo = require('../../file-operations'); var readStream = require('../../src/get-contents/read-stream'); -function writeStream(writePath, file, written) { +function writeStream(file, written) { var opt = { mode: file.stat.mode, flag: file.flag, }; - var outStream = fs.createWriteStream(writePath, opt); + var outStream = fs.createWriteStream(file.path, opt); file.contents.once('error', complete); file.contents.once('end', readStreamEnd); diff --git a/lib/dest/write-contents/write-symbolic-link.js b/lib/dest/write-contents/write-symbolic-link.js index b0969692..954e47bc 100644 --- a/lib/dest/write-contents/write-symbolic-link.js +++ b/lib/dest/write-contents/write-symbolic-link.js @@ -2,9 +2,9 @@ var fs = require('graceful-fs'); -function writeSymbolicLink(writePath, file, written) { +function writeSymbolicLink(file, written) { // TODO handle symlinks properly - fs.symlink(file.symlink, writePath, function(err) { + fs.symlink(file.symlink, file.path, function(err) { if (isFatalError(err)) { return written(err); } diff --git a/lib/prepare-write.js b/lib/prepare-write.js index e6f2aa89..eafacd4f 100644 --- a/lib/prepare-write.js +++ b/lib/prepare-write.js @@ -57,7 +57,7 @@ function prepareWrite(outFolder, file, opt, cb) { if (err) { return cb(err); } - cb(null, writePath); + cb(null); }); } diff --git a/lib/symlink/index.js b/lib/symlink/index.js index 93b6b9aa..94248ef8 100644 --- a/lib/symlink/index.js +++ b/lib/symlink/index.js @@ -8,11 +8,11 @@ function symlink(outFolder, opt) { function linkFile(file, enc, cb) { var srcPath = file.path; var symType = (file.isDirectory() ? 'dir' : 'file'); - prepareWrite(outFolder, file, opt, function(err, writePath) { + prepareWrite(outFolder, file, opt, function(err) { if (err) { return cb(err); } - fs.symlink(srcPath, writePath, symType, function(err) { + fs.symlink(srcPath, file.path, symType, function(err) { if (err && err.code !== 'EEXIST') { return cb(err); }