Methods
(async) argsHandle()
Handle command line arguments given to the main.js program.
sanitises and handles the command-line arguments provided.
Accepts a path from the command line via minimist args.
cleanBashRoot(_path) → {string}
Catches an error with the '/' unix root in a bash shell.
When '/' root is used, bash thinks root = 'C:/Program Files/Git'.
Returns a clean unix root path.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be cleaned. |
Returns:
The clean unix path.
- Type
- string
cleanCwdSyncPipe() → {function}
Compose the cwd cleaning sync pipe.
Assume: process.cwd() is always absolute and not a file url.
Returns:
The composed cwd cleaning sync pipe.
- Type
- function
cleanFileURL(_path) → {string}
Cleans a file URL into a path.
Uses fileURLToPath from the url standard library.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The file URL to be cleaned. |
Returns:
The clean path.
- Type
- string
cleanGlobSyncPipe() → {function}
Compose path cleaning sync pipe for the output filepaths of a glob search.
*
Returns:
The composed glob path cleaning pipe.
- Type
- function
cleanPathAsyncPipe() → {function}
Compose the path cleaning async pipe.
Returns:
The composed path cleaning pipe.
- Type
- function
cleanSysRoot(_path) → {string}
Trims 'C:' from system drive paths.
Leaves other drive letters and delimiters intact.
Clean --path C: drive root into unix / root.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be cleaned. |
Returns:
The clean path.
- Type
- string
getFiles(_path, ext, recurse) → {array}
Search for files and get matching absolute paths.
If _path is ommitted the current working directory is defaulted to.
If extension is ommitted no file extension is added.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The directory path to search for matches. |
ext |
string | {optional} The file extension (including the dot) to search for. |
recurse |
string | {optional} flag for recursive glob search. |
Returns:
The list of matching paths in posix format.
- Type
- array
(async) init()
Initiate module functions in sequence of clean, check, get, use.
Is called after sanitising the command-line arguments provided.
Accepts a path from the command line via minimist args.
inOS(_path) → {boolean}
Returns true if path root contains the operating system.
Root may be represented as '/' or 'C:\'.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be checked. |
Returns:
True if path is in OS, false if not.
- Type
- boolean
isFile(_path) → {boolean}
Returns true if path leads to a file.
Includes files without extensions.
Touches the file system and needs error handling.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be checked. |
Returns:
True if path is a file, false if it is a directory.
- Type
- boolean
isLetter(letter) → {boolean}
Returns true if value exists and is a cased letter.
Cleverly checks if both-cases of a char are different.
From: https://stackoverflow.com/a/32567789
Parameters:
Name | Type | Description |
---|---|---|
letter |
string | The value to be checked. |
Returns:
True if a cased letter, false if not.
- Type
- boolean
isSafeWinPath(_path) → {boolean}
Returns true if path is safe to edit.
If not in OS or if in OS but not in a system path
Stops editing of windows operating system files.
Allows editing across different letter drives.
Wraps other functions from this module in conditional logic.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be checked. |
Returns:
True if path is safe, false if not.
- Type
- boolean
isString(_path) → {boolean}
Returns true if value exists and is a string.
*
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The value to be checked. |
Returns:
True if string, false if not.
- Type
- boolean
isSystemPath(_path) → {boolean}
Checks if path contains windows system directories.
Assumes input to be a POSIX path on the operating system drive.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be checked. |
Returns:
Returns true for system paths, false if not.
- Type
- boolean
(async) pipeHandle(_path, pipe)
Runs composed sync and async pipes.
run path cleaning and safety checking functions.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be piped. |
pipe |
function | The pipe function to use. (default to cleanPathAsyncPipe?) |
Returns:
The clean path on success, false on error.
posixPath(_path) → {string}
Sanitises input path into a posix path.
Leaves drive letters intact.
Parameters:
Name | Type | Description |
---|---|---|
_path |
string | The path to be sanitised. |
Returns:
The sanitised posix path.
- Type
- string
(async) promptHandle(message) → {string}
Uses prompts module to ask for a new path.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Optional custom message to use in prompt. |
Returns:
The new path from prompt response.
- Type
- string
syncPipe() → {function}
Create a n pipe composer using spread and reduce.
Is fully synchronous and does not handle promises.
Only keeping to minimise async/await functions.
Returns:
The pipe composer function.
- Type
- function
tweakTags(files, tag, find, replace)
Reads ID3 tag values, edits them and saves changes to file.
Parameters:
Name | Type | Description |
---|---|---|
files |
Array.<string> | The targeted mp3 files. |
tag |
string | The key name of the target tag. |
find |
string | The substring of the target tag to be replaced. |
replace |
string | The replacement substring for the target tag. |
- Source:
tweakTagsObject(tags, tag, find, replace) → {Object}
ID3 tag substring replacer/remover.
this could accept a general metadata object if it were flat
Parameters:
Name | Type | Description |
---|---|---|
tags |
Object | The ID3 tags object of an mp3 file. |
tag |
string | The keyname of the tag to be targeted. |
find |
string | The substring of the target tag to be replaced. |
replace |
string | The replacement substring for the target tag. |
- Source:
Returns:
The updated ID3 tags object of an mp3 file.
- Type
- Object