1.0.0 • Published 5 years ago

@davehermann/fs-utilities v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@davehermann/fs-utilities

Personal file system utilities that someone else might find useful

July 2020

  • Updated to Typescript, with typescript definitions included

CLI

  • New in 1.0.0
  • Perfect for package.json pre/post-build scripts' file management with Typescript
  • Works on files or directories
  • Gracefully skips missing paths

Installs as fsutility locally or globally

Copy

fsutility copy path-to-source path-to-destination

Delete

fsutility delete path-to-object

Move

fsutility move path-to-source path-to-destination

API

#CopyPath(sourcePath, destinationPath, verbose)

  • Copy file/directory specified by sourcePath to destinationPath
PropertyTypeRequiredNotes
sourcePathstringyesabsolute path to the file system object to be copied
destinationPathstringyesabsolute path to the file system location where the copy will reside
verbosebooleannoDefault: falseOutput copy steps to console

#EnsurePathForFile(fullPathWithFile)

  • Creates any missing directories in the file system that appear within the path to the file
PropertyTypeRequiredNotes
fullPathWithFilestringyesThe absolute path to the to-be-created file

#MovePath(sourcePath, destinationPath, verbose)

  • Move file/directory specified by sourcePath to destinationPath
PropertyTypeRequiredNotes
sourcePathstringyesabsolute path to the file system object currently
destinationPathstringyesabsolute path to the file system location for future use
verbosebooleannoDefault: falseOutput move steps to console

#ReadSubDirectories(pathToRead, options)

Reads all file system objects in a directory, and returns fs.stat() on each as well as nested subdirectories and their objects

PropertyTypeRequiredNotes
pathToReadstringyesDirectory to start reading
optionsReadOptionsnoOptions for reading

ReadOptions class

PropertyTypeRequiredNotes
returnPropertiesstring[]noList of fs.Stats properties to returnReturns all properties by defaultSee NodeJS FS Stats class documentation for your NodeJS version to see available properties

#RemovePath(fileSystemPath, verbose)

  • Delete file/directory specified by fileSystemPath
PropertyTypeRequiredNotes
fileSystemPathstringyesabsolute path to the file system object
verbosebooleannoDefault: falseOutput remove steps to console