
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
enfsensure-promise
Advanced tools
Ensure file, folder, link or symlink existence in file system for node fs module with promises
Module that add ensure functionality to node fs module with promises
enfs stands for [E]asy [N]ode [fs]
This module is intended to work as a sub-module of enfs
This module will add various method that allows the user to ensure the creation of a file, directory, link or symlink in the file system, if the parent directory of the item to be ensured don't exist it will be automatically created.
ensureFile
ensureFileSync
ensureDir
ensureDirSync
ensureLink
ensureLinkSync
ensureSymlink
ensureSymlinkSync
ensureFileP
ensureDirP
ensureLinkP
ensureSymlinkP
enfsensure
const enfsensure = require("enfsensure-promise");
All the methods follows the node culture.
Ensures the file existence in the file system, if the file don't exist it will be created.
[options]:
Sync: * ensureFileSync(path,[options])
enfsensure.ensureFile("/path/to/any/file",{ data: "contents", encoding: "utf8" },function(err){
if(!err){
console.log("data was written to the file");
}
});
Stream
enfsensure.ensureFile("/path/to/any/file",{ stream: true, streamOptions: { autoClose: true} },function(err, stream){
if(!err){
console.log("stream is a WriteStream object.");
}
});
Ensure directory existence in the file system, if directory don't exist it will be created
[options]:
Sync: * ensureDirSync(path,[options])
enfsensure.ensureDir("/path/to/the/new/folder", function(err, path){
if(!err){
console.log("directory was created in the path: "+path);
}
});
Ensure link creation in the file system. link
[options]:
Sync: * ensureLinkSync(srcPath, dstPath, [options])
enfsensure.ensureLink("/srcPath", "/dstPath", function(err, dstPath){
//do something
});
Ensure symlink creation in the file system. symlink
[options]:
Sync: * ensureSymlinkSync(path,[options])
enfsensure.ensureSymlink("./foo", "./new-port", "file", function(err, dstPath){
//do something
});
Ensures the file existence in the file system, if the file don't exist it will be created.
[options]:
enfsensure.ensureFileP("/path/to/any/file",{ data: "contents", encoding: "utf8" }).then(function(){
console.log("data was written to the file");
});
Stream
enfsensure.ensureFileP("/path/to/any/file",{ stream: true, streamOptions: { autoClose: true} }).then(function(stream){
console.log("stream is a WriteStream object.");
});
Ensure directory existence in the file system, if directory don't exist it will be created
[options]:
enfsensure.ensureDirP("/path/to/the/new/folder").then(function(path){
console.log("directory was created in the path: "+path);
});
Ensure link creation in the file system. link
[options]:
enfsensure.ensureLinkP("/srcPath", "/dstPath").then(function(dstPath){
//do something
});
Ensure symlink creation in the file system. symlink
[options]:
enfsensure.ensureSymlinkP("./foo", "./new-port", "file").then(function(dstPath){
//do something
});
Creative Commons Attribution 4.0 International License
Copyright (c) 2016 Joao Parreira joaofrparreira@gmail.com GitHub
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit CC-BY-4.0.
FAQs
Ensure file, folder, link or symlink existence in file system for node fs module with promises
We found that enfsensure-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.