Socket
Socket
Sign inDemoInstall

fs-jetpack

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-jetpack - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

36

lib/copy.js

@@ -57,3 +57,15 @@ "use strict";

var symlinkPointsAt = fs.readlinkSync(inspectData.absolutePath);
fs.symlinkSync(symlinkPointsAt, to);
try {
fs.symlinkSync(symlinkPointsAt, to);
} catch (err) {
// There is already file/symlink with this name on destination location.
// Must erase it manually, otherwise system won't allow us to place symlink there.
if (err.code === 'EEXIST') {
fs.unlinkSync(to);
// Retry...
fs.symlinkSync(symlinkPointsAt, to);
} else {
throw err;
}
}
}

@@ -91,2 +103,3 @@ };

var promisedReadlink = Q.denodeify(fs.readlink);
var promisedUnlink = Q.denodeify(fs.unlink);
var promisedMkdirp = Q.denodeify(mkdirp);

@@ -106,3 +119,22 @@

.then(function (symlinkPointsAt) {
return promisedSymlink(symlinkPointsAt, to);
var deferred = Q.defer();
promisedSymlink(symlinkPointsAt, to)
.then(deferred.resolve)
.catch(function (err) {
if (err.code === 'EEXIST') {
// There is already file/symlink with this name on destination location.
// Must erase it manually, otherwise system won't allow us to place symlink there.
promisedUnlink(to)
.then(function () {
// Retry...
return promisedSymlink(symlinkPointsAt, to)
})
.then(deferred.resolve, deferred.reject);
} else {
deferred.reject(err);
}
});
return deferred.promise;
});

@@ -109,0 +141,0 @@ }

2

package.json
{
"name": "fs-jetpack",
"description": "Better file system API",
"version": "0.7.2",
"version": "0.7.3",
"author": "Jakub Szwacz <jakub@szwacz.com>",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -499,4 +499,33 @@ /* eslint-env jasmine */

it('can overwrite symlink', function (done) {
var preparations = function () {
helper.clearWorkingDir();
fse.mkdirsSync('to_copy');
fse.symlinkSync('some/file', 'to_copy/symlink');
fse.mkdirsSync('copied');
fse.symlinkSync('some/other_file', 'copied/symlink');
};
var expectations = function () {
expect(fse.lstatSync('copied/symlink').isSymbolicLink()).toBe(true);
expect(fse.readlinkSync('copied/symlink')).toBe('some/file');
};
// SYNC
preparations();
jetpack.copy('to_copy', 'copied', { overwrite: true });
expectations();
// ASYNC
preparations();
jetpack.copyAsync('to_copy', 'copied', { overwrite: true })
.then(function () {
expectations();
done();
});
});
});
});
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