1. hidefile
Hide files and directories on all platforms.
hidefile
Package: hidefile
Created by: stevenvachon
Last modified: Sat, 18 Jun 2022 20:38:23 GMT
Version: 3.0.0
License: MIT
Downloads: 249,886
Repository: https://github.com/stevenvachon/hidefile

Install

npm install hidefile
yarn add hidefile

hidefile NPM Version Linux Build Windows Build Coverage Status Dependency Monitor

Hide files and directories on all platforms.

Unix:

  • Adds or removes a "." prefix on a file or dir

Windows:

  • Adds or removes a "." prefix on a file or dir
  • Adds or removes the "hidden" attribute on a file or dir

A native binding is used, offering great performance. As a contingency in case that fails, functionality will silently revert to a command line, though it is considerably slower.

Installation

Node.js >= 8 is required. To install, type this at the command line:

npm install hidefile

Methods

hide(path, callback)

path - Path to file or directory
callback(err,newpath) - A callback which is called upon completion

 hidefile.hide('path/to/file.ext', (err, newpath) => {
  if (err == null) {
    console.log(newpath);  //-> 'path/to/.file.ext'
  }
});

hideSync(path)

path - Path to file or directory

Throws an error if the file or dir cannot be found/accessed.

 const newpath = hidefile.hideSync('path/to/file.ext');

console.log(newpath);  //-> 'path/to/.file.ext'

isDotPrefixed(path)

path - Path to file or directory

 console.log( hidefile.isDotPrefixed('path/to/.file.ext') );  //-> true
console.log( hidefile.isDotPrefixed('path/to/file.ext') );   //-> false

isHidden(path, callback)

path - Path to file or directory
callback(result) - A callback which is called upon completion

 hidefile.isHidden('path/to/file.ext', (err, result) => {
  if (err == null) {
    console.log(result);  //-> false
  }
});

Unix: result is true if prefixed.
Windows: result is true if prefixed and has "hidden" attribute, false if only prefixed.

isHiddenSync(path)

path - Path to file or directory

Throws an error if the file or dir cannot be found/accessed.

 const result = hidefile.isHiddenSync('path/to/file.ext');

console.log(result);  //-> false

reveal(path, callback)

path - Path to file or directory
callback(err,newpath) - A callback which is called upon completion

 hidefile.reveal('path/to/.file.ext', (err, newpath) => {
  if (err == null) {
    console.log(newpath);  //-> 'path/to/file.ext'
  }
});

revealSync(path)

path - Path to file or directory

Throws an error if the file or dir cannot be found/accessed.

 const newpath = hidefile.revealSync('path/to/.file.ext');

console.log(newpath);  //-> 'path/to/file.ext'

shouldBeHidden(path, callback)

path - Path to file or directory
callback(result) - A callback which is called upon completion

 if (isWindows) {
  hidefile.shouldBeHidden('path/to/.file.ext', (err, result) => {
    if (err == null) {
      console.log(result);  //-> true
    }
  });
}

Unix: result is true if prefixed.
Windows: result is true if prefixed or has "hidden" attribute.

shouldBeHiddenSync(path)

path - Path to file or directory

Throws an error if the file or dir cannot be found/accessed.

 if (isWindows) {
  result = hidefile.shouldBeHiddenSync('path/to/.file.ext');

  console.log(result);  //-> true
}

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin