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

lnfs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lnfs - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

cli.js

63

index.js
'use strict';
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
var path = require('path');
var rm = require('rimraf');
var rimraf = require('rimraf');
/**
* Create symlink
*
* @param {String} src
* @param {String} dest
* @param {String} type
* @param {Function} cb
* @api private
*/
function link(src, dest, type, cb) {
rm(dest, function (err) {
rimraf(dest, function (err) {
if (err) {

@@ -36,27 +25,21 @@ cb(err);

/**
* Async
*
* @param {String} src
* @param {String} dest
* @param {String} type
* @param {Function} cb
* @api public
*/
module.exports = function (src, dest, type, cb) {
src = path.resolve(src);
dest = path.resolve(dest);
if (typeof src !== 'string' || typeof dest !== 'string') {
throw new Error('Source file and target required');
}
if (typeof type === 'function' && !cb) {
cb = type;
type = 'file';
type = null;
}
src = path.resolve(src);
dest = path.resolve(dest);
fs.lstat(dest, function (err, stats) {
if (err && err.code === 'ENOENT') {
return link(src, dest, type, cb);
}
if (err) {
if (err.code === 'ENOENT') {
return link(src, dest, type, cb);
}
cb(err);

@@ -86,15 +69,9 @@ return;

/**
* Sync
*
* @param {String} src
* @param {String} dest
* @param {String} type
* @api public
*/
module.exports.sync = function (src, dest, type) {
if (typeof src !== 'string' || typeof dest !== 'string') {
throw new Error('Source file and target required');
}
module.exports.sync = function (src, dest, type) {
src = path.resolve(src);
dest = path.resolve(dest);
type = type || 'file';

@@ -106,3 +83,3 @@ try {

if (!stats.isSymbolicLink()) {
rm.sync(dest);
rimraf.sync(dest);
fs.symlinkSync(src, dest, type);

@@ -116,3 +93,3 @@ return;

rm.sync(dest);
rimraf.sync(dest);
fs.symlinkSync(src, dest, type);

@@ -119,0 +96,0 @@ } catch (err) {

{
"name": "lnfs",
"version": "1.0.0",
"version": "1.1.0",
"description": "Safely force create symlinks",

@@ -15,2 +15,3 @@ "license": "MIT",

},
"bin": "cli.js",
"scripts": {

@@ -20,2 +21,3 @@ "test": "node test.js"

"files": [
"cli.js",
"index.js"

@@ -25,2 +27,3 @@ ],

"dependencies": {
"meow": "^3.3.0",
"mkdirp": "^0.5.0",

@@ -27,0 +30,0 @@ "rimraf": "^2.2.8"

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