Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-plus

Package Overview
Dependencies
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-plus - npm Package Compare versions

Comparing version 2.7.1 to 2.8.0

67

lib/fs-plus.js
(function() {
var Module, async, fs, fsPlus, isPathValid, lstatSyncNoException, mkdirp, path, rimraf, statSyncNoException, _,
var Module, async, fs, fsPlus, isMoveTargetValid, isMoveTargetValidSync, isPathValid, lstatSyncNoException, mkdirp, path, rimraf, statSyncNoException, _,
__slice = [].slice;

@@ -229,3 +229,42 @@

},
move: function(source, target, callback) {
return isMoveTargetValid(source, target, function(isMoveTargetValidErr, isTargetValid) {
var error, targetParentPath;
if (isMoveTargetValidErr) {
callback(isMoveTargetValidErr);
return;
}
if (!isTargetValid) {
error = new Error("'" + target + "' already exists.");
error.code = 'EEXIST';
callback(error);
return;
}
targetParentPath = path.dirname(target);
return fs.exists(targetParentPath, function(targetParentExists) {
if (targetParentExists) {
fs.rename(source, target, callback);
return;
}
return fsPlus.makeTree(targetParentPath, function(makeTreeErr) {
if (makeTreeErr) {
callback(makeTreeErr);
return;
}
return fs.rename(source, target, callback);
});
});
});
},
moveSync: function(source, target) {
var error, targetParentPath;
if (!isMoveTargetValidSync(source, target)) {
error = new Error("'" + target + "' already exists.");
error.code = 'EEXIST';
throw error;
}
targetParentPath = path.dirname(target);
if (!fs.existsSync(targetParentPath)) {
fsPlus.makeTreeSync(targetParentPath);
}
return fs.renameSync(source, target);

@@ -528,4 +567,30 @@ },

isMoveTargetValid = function(source, target, callback) {
return fs.stat(source, function(oldErr, oldStat) {
if (oldErr) {
callback(oldErr);
return;
}
return fs.stat(target, function(newErr, newStat) {
if (newErr && newErr.code === 'ENOENT') {
callback(void 0, true);
return;
}
return callback(void 0, source.toLowerCase() === target.toLowerCase() && oldStat.dev === newStat.dev && oldStat.ino === newStat.ino);
});
});
};
isMoveTargetValidSync = function(source, target) {
var newStat, oldStat;
oldStat = statSyncNoException(source);
newStat = statSyncNoException(target);
if (!(oldStat && newStat)) {
return true;
}
return source.toLowerCase() === target.toLowerCase() && oldStat.dev === newStat.dev && oldStat.ino === newStat.ino;
};
module.exports = _.extend({}, fs, fsPlus);
}).call(this);

2

package.json
{
"name": "fs-plus",
"version": "2.7.1",
"version": "2.8.0",
"description": "node's fs with more helpers",

@@ -5,0 +5,0 @@ "main": "./lib/fs-plus.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc