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

enfsensure

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enfsensure - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

1.0.0 / 2017-02-20
==================
* code improvement
* dependencies upgrade
* major version
0.1.0 / 2016-04-06

@@ -2,0 +8,0 @@ ==================

0

index.js

@@ -0,0 +0,0 @@ /**

5

lib/async/dir.js

@@ -16,3 +16,2 @@ /**

const nodePath = require("path");
const enFs = require("enfspatch");

@@ -56,3 +55,3 @@ const enfsmkdirp = require("enfsmkdirp");

if (options.mode) {
options.fs.stat(path, (errStat, stat)=> {
options.fs.stat(path, (errStat, stat) => {
if (errStat) {

@@ -62,3 +61,3 @@ return callback(errStat);

if ((stat.mode & parseInt("0777", 8)) !== options.mode) {
options.fs.chmod(path, options.mode, (errChmod)=> {
options.fs.chmod(path, options.mode, (errChmod) => {
return callback(errChmod || null, errChmod ? null : path);

@@ -65,0 +64,0 @@ });

@@ -24,2 +24,43 @@ /**

function ensureWriteStream(path, options, callback) {
try {
return callback(null, options.fs.createWriteStream(path, options.streamOptions));
} catch (err) {
callback(err);
}
}
function ensureWriteFile(file, options, callback) {
options.fs.open(file, options.append ? "a+" : "wx", options.mode, (errOpen, fd) => {
if (errOpen) {
return callback(errOpen);
}
if ("data" in options) {
options.fs.write(fd, options.data, options.encoding, (errWrite) => {
if (errWrite) {
return callback(errWrite);
}
options.fs.close(fd, callback);
});
} else {
options.fs.close(fd, callback);
}
});
}
function createFile(file, options, callback) {
ensureDir(nodePath.dirname(file), {fs: options.fs, mode: options.dirMode}, (err) => {
if (err) {
return callback(err);
}
if (options.stream) {
ensureWriteStream(file, options, callback);
} else {
ensureWriteFile(file, options, callback);
}
});
}
/**

@@ -41,3 +82,2 @@ * ensure - ensures file existence on file system

function ensure(path, opt, callback) {
let options;

@@ -52,3 +92,3 @@ if (ensureUtil.isFunction(opt)) {

callback = callback || noop;
options = opt || {};
let options = opt || {};

@@ -60,3 +100,3 @@ options.fs = options.fs || enFs;

options.fs.stat(path, (err, stat)=> {
options.fs.stat(path, (err, stat) => {
if (err) {

@@ -94,44 +134,2 @@ createFile(path, options, callback);

function createFile(file, options, callback) {
ensureDir(nodePath.dirname(file), {fs: options.fs, mode: options.dirMode}, (err)=> {
if (err) {
return callback(err);
}
if (options.stream) {
ensureWriteStream(file, options, callback);
} else {
ensureWriteFile(file, options, callback);
}
});
}
function ensureWriteStream(path, options, callback) {
var stream;
try {
stream = options.fs.createWriteStream(path, options.streamOptions);
return callback(null, stream);
} catch (err) {
callback(err);
}
}
function ensureWriteFile(file, options, callback) {
options.fs.open(file, options.append ? "a+" : "wx", options.mode, (errOpen, fd) => {
if (errOpen) {
return callback(errOpen);
}
if (options.hasOwnProperty("data")) {
options.fs.write(fd, options.data, options.encoding, (errWrite) => {
if (errWrite) {
return callback(errWrite);
}
options.fs.close(fd, callback);
});
} else {
options.fs.close(fd, callback);
}
});
}
module.exports = ensure;

@@ -23,2 +23,14 @@ /**

function createLink(srcPath, dstPath, options, callback) {
ensureDir(nodePath.dirname(dstPath), (err) => {
if (err) {
return callback(err);
}
options.fs.link(srcPath, dstPath, (errLink) => {
callback(errLink, errLink ? null : dstPath);
});
});
}
/**

@@ -38,3 +50,3 @@ * ensure - ensures link existence on file system

callback = opt;
opt= {};
opt = {};
}

@@ -45,3 +57,3 @@ callback = callback || noop;

options.fs.lstat(dstPath, (errDstStat)=> {
options.fs.lstat(dstPath, (errDstStat) => {
if (errDstStat) {

@@ -61,14 +73,3 @@ options.fs.lstat(srcPath, (errSrcStat) => {

function createLink(srcPath, dstPath, options, callback) {
ensureDir(nodePath.dirname(dstPath), (err) => {
if (err) {
return callback(err);
}
options.fs.link(srcPath, dstPath, (errLink) => {
callback(errLink, errLink ? null : dstPath);
});
});
}
module.exports = ensure;

@@ -64,3 +64,3 @@ /**

}
ensureDir(nodePath.dirname(dstPath), (errDir)=> {
ensureDir(nodePath.dirname(dstPath), (errDir) => {
if (errDir) {

@@ -67,0 +67,0 @@ return callback(errDir);

@@ -42,3 +42,2 @@ /**

function symlinkPaths(srcPath, dstPath, callback) {
var dstDir, relativeToDst;
if (nodePath.isAbsolute(srcPath)) {

@@ -53,4 +52,4 @@ return enFs.lstat(srcPath, (errSrcStat) => {

} else {
dstDir = nodePath.dirname(dstPath);
relativeToDst = nodePath.join(dstDir, srcPath);
const dstDir = nodePath.dirname(dstPath);
const relativeToDst = nodePath.join(dstDir, srcPath);
return enFs.lstat(relativeToDst, (errRelative) => {

@@ -57,0 +56,0 @@ if (errRelative) {

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -15,3 +15,2 @@ /**

const nodePath = require("path");
const enFs = require("enfspatch");

@@ -18,0 +17,0 @@ const enfsmkdirp = require("enfsmkdirp");

@@ -21,2 +21,25 @@ /**

function ensureWriteStream(path, options) {
return options.fs.createWriteStream(path, options.streamOptions);
}
function ensureWriteFile(file, options) {
const fd = options.fs.openSync(file, options.append ? "a+" : "wx", options.mode);
if (options.hasOwnProperty("data")) {
options.fs.writeSync(fd, options.data, options.encoding);
}
options.fs.closeSync(fd);
}
function createFileSync(file, options) {
ensureDirSync(nodePath.dirname(file), {fs: options.fs, mode: options.dirMode});
if (options.stream) {
return ensureWriteStream(file, options);
} else {
ensureWriteFile(file, options);
}
}
/**

@@ -70,24 +93,2 @@ * ensure - ensures file existence on file system

function createFileSync(file, options) {
ensureDirSync(nodePath.dirname(file), {fs: options.fs, mode: options.dirMode});
if (options.stream) {
return ensureWriteStream(file, options);
} else {
ensureWriteFile(file, options);
}
}
function ensureWriteStream(path, options) {
return options.fs.createWriteStream(path, options.streamOptions);
}
function ensureWriteFile(file, options) {
const fd = options.fs.openSync(file, options.append ? "a+" : "wx", options.mode);
if (options.hasOwnProperty("data")) {
options.fs.writeSync(fd, options.data, options.encoding);
}
options.fs.closeSync(fd);
}
module.exports = ensure;

@@ -16,3 +16,2 @@ /**

const nodePath = require("path");
const ensureUtil = require("../util");
const enFs = require("enfspatch");

@@ -19,0 +18,0 @@ const ensureDir = require("./dir");

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -16,8 +16,8 @@ /**

let util = {};
util.kindOf = (arg) => arg === null ? "null" : arg === undefined ? "undefined" : /^\[object (.*)\]$/.exec(Object.prototype.toString.call(arg))[1];
util.kindOf = (arg) => arg === null ? "null" : typeof arg === "undefined" ? "undefined" : /^\[object (.*)\]$/.exec(Object.prototype.toString.call(arg))[1];
util.isKind = (arg, kind) => util.kindOf(arg).toLowerCase() === kind.toLowerCase();
util.isFunction = (arg) => util.isKind(arg, "function");
util.isObject = (arg) => arg !== null && arg !== undefined && util.isKind(arg, "object");
util.isObject = (arg) => arg !== null && typeof arg !== "undefined" && util.isKind(arg, "object");
util.isString = (arg) => util.isKind(arg, "string");
module.exports = util;
{
"name": "enfsensure",
"version": "0.1.0",
"version": "1.0.0",
"description": "Ensure file, folder, link or symlink existence in file system for node fs module",

@@ -30,11 +30,11 @@ "license": "CC-BY-4.0",

"dependencies": {
"enfsmkdirp": "0.1",
"enfspatch": "0.1"
"enfsmkdirp": "^1.0",
"enfspatch": "^1.0"
},
"devDependencies": {
"eslint": "2.7.0",
"eslint-plugin-mocha": "2.1.0",
"mocha": "2.4.5",
"should": "8.3.0",
"rimraf": "2.5.2"
"eslint": "^3.18.0",
"eslint-plugin-mocha": "^4.9.0",
"mocha": "^3.2.0",
"should": "^11.2.1",
"rimraf": "^2.6.1"
},

@@ -41,0 +41,0 @@ "keywords": [

@@ -0,0 +0,0 @@ [![Build Status](https://travis-ci.org/n3okill/enfsensure.svg)](https://travis-ci.org/n3okill/enfsensure)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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