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

fsensure

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fsensure

Ensure directories and files exists or that they are removed.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

fsensure

Ensure directories and files exists or are removed in Node.js.

Install

Using npm:

npm install fsensure

##Examples

Create directories recursively like mkdir -p:

var fsensure = require('fsensure');

fsensure.dir.exists('/tmp/foo/bar/baz', function (err) {
    if (err) { console.error(err); return; }
    console.log('/tmp/foo/bar/baz now exists');
});

Move files around and automatically create the required directories:

var fsensure = require('fsensure');

fsensure.file.move('/tmp/info.txt', '/tmp/archive/info.md', function (err) {
    if (err) { console.error(err); return; }
    console.log('/tmp/info.txt moved to /tmp/archive/info.md');
});

Methods

dir.exists(path, [mode], callback)

Ensure that directory exists. If directory does not exist, try to create the directory in path. Understand the path as a path to directory.

dir.existsSync(path, [mode])

Sync version of fsensure.dir.exists.

file.move(source, target, callback)

Alias of fsensure.file.rename.

file.rename(source, target, callback)

First ensures that the directories of the target filepath exists, creates the directories then renames the file.

file.dir.exists(filepath, callback)

Ensures that the directories of filepath exist. Difference to dir.exists is that here filepath is understood as path to a non-directory file.

file.copy(source, target, callback)

Ensure that target path exists and copy the file.

file.remove(target, callback)

Alias of fsensure.file.unlink

file.unlink(target, callback)

Ensure that target file is removed. Remove the file if possible.

TODO

  • more tests
  • more comprehensive documentation
  • file.dir.existsSync

Keywords

FAQs

Package last updated on 20 Oct 2013

Did you know?

Socket

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.

Install

Related posts

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