Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove superfluous argument from write-xxx modules #173

Merged
merged 1 commit into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/dest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ function dest(outFolder, opt) {
}

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);
});
}

Expand Down
10 changes: 5 additions & 5 deletions lib/dest/write-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/dest/write-contents/write-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions lib/dest/write-contents/write-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions lib/dest/write-contents/write-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ var fs = require('graceful-fs');
var fo = require('../../file-operations');
var streamFile = require('../../src/get-contents/stream-file');

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);
Expand Down
4 changes: 2 additions & 2 deletions lib/dest/write-contents/write-symbolic-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/prepare-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function prepareWrite(outFolder, file, opt, cb) {
if (err) {
return cb(err);
}
cb(null, writePath);
cb(null);
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/symlink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down