refactor(rest) add isRootAll

This commit is contained in:
coderaiser 2015-05-31 09:30:24 -04:00
parent 394314dd3d
commit 83e2a187de

View file

@ -189,15 +189,8 @@
case 'mv':
if (!files.from || !files.to) {
callback(body);
} else if (isRootWin32(files.to)) {
error = getWin32RootMsg('to');
callback(error);
} else if (isRootWin32(files.from)) {
error = getWin32RootMsg('from');
callback(error);
} else if (isRootAll([files.to, files.from])) {
callback(getWin32RootMsg());
} else {
files.from = root(files.from);
files.to = root(files.to);
@ -219,14 +212,8 @@
case 'cp':
if (!files.from || !files.names || !files.to) {
callback(body);
} else if (isRootWin32(files.to)) {
error = getWin32RootMsg('to');
callback(error);
} else if (isRootWin32(files.from)) {
error = getWin32RootMsg('from');
callback(error);
} else if (isRootAll([files.to, files.from])) {
callback(getWin32RootMsg());
} else {
files.from = root(files.from);
files.to = root(files.to);
@ -351,11 +338,16 @@
return isWin32 && isRoot && isConfig;
}
function getWin32RootMsg(direction) {
var messageRaw = 'Could not copy {{ direction }} root on windows!',
message = rendy(messageRaw, {
direction: direction
}),
function isRootAll(names) {
var is = names.some(function(name) {
return isRootWin32(name);
});
return is;
}
function getWin32RootMsg() {
var message = 'Could not copy from/to root on windows!',
error = Error(message);
return error;