trash-sync
v1.1.0
Published
A tiny NodeJS CJS module to trash files and directories synchronously
Downloads
5
Readme
Trash-Sync
Table of Contents generated with DocToc
A tiny NodeJS CJS module to trash files and directories synchronously
Trash-Sync
trash-sync allows to trash files synchronously. This comes handy if you have a fully synchronous piece of
software and want to avoid to make everything asynchronous just to delete a file the safe way. trash-sync
uses sindresorhus/trash, which see for features and limitations.
trash-sync exports a single function, trash(), that takes as its only argument a path to the file system
object you want to delete. It will
- return
0if there was nothing to trash; - return
1if a file or directory has been trashed - throw an error where
sindresorhus/trashthrows an error, most commonly when a user with insufficient privileges tries to trash a file
Example:
{ trash, } = require( 'trash-sync' );
console.log( "trashed ", trash( 'path/to/file' ), " file(s)." );To Do
- [+] make
trashimportable through submodule - [+]
cdto correct directory beforespawnSync()
