hidefile
Version:
Hide files and directories on all platforms.
70 lines (50 loc) • 1.82 kB
Markdown
> Hide files and directories on all platforms.
Unix:
- Adds or removes a "." prefix on a file or directory.
Windows:
- Adds or removes a "." prefix on a file or directory.
- Adds or removes the "hidden" attribute on a file or directory.
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.
```shell
npm install hidefile
```
```js
import { hide, hideSync, reveal, revealSync } from 'hidefile';
await hide('path/to/file.ext'); //-> 'path/to/.file.ext'
hideSync('path/to/file.ext'); //-> 'path/to/.file.ext'
await reveal('path/to/.file.ext'); //-> 'path/to/file.ext'
revealSync('path/to/.file.ext'); //-> 'path/to/file.ext'
```
```js
import {
isDotPrefixed,
isHidden,
isHiddenSync,
shouldBeHidden,
shouldBeHiddenSync,
} from 'hidefile';
isDotPrefixed('path/to/.file.ext'); //-> true
isDotPrefixed('path/to/file.ext'); //-> false
/*
Unix: prefixed
Windows: prefixed _and_ attributed
*/
await isHidden('path/to/.file.ext'); //-> true
isHiddenSync('path/to/.file.ext'); //-> true
/*
Unix: prefixed
Windows: prefixed _or_ attributed
*/
await shouldBeHidden('path/to/.file.ext'); //-> true
shouldBeHiddenSync('path/to/.file.ext'); //-> true
```
[]: https://img.shields.io/npm/v/hidefile
[]: https://npmjs.com/package/hidefile
[]: https://img.shields.io/github/actions/workflow/status/stevenvachon/hidefile/test.yml
[]: https://img.shields.io/codecov/c/github/stevenvachon/hidefile
[]: https://app.codecov.io/github/stevenvachon/hidefile