- syncGlob
- NotifyCallback
- CloseFunc
- copyFile
- copyDir
- remove
- TransformFunc
- isGlob
- resolveTarget
- ResolveTargetFunc
- sourcesBases
- trimQuotes
Synchronise files, directories and/or glob patterns, optionally watching for changes.
Parameters
sources(string | Array<string>) A list of files, directories and/or glob patterns.targetstring The destination directory.optionsObject? An optional configuration object.options.watchbool? Enable or disable watch mode. (optional, defaultfalse)options.deletebool? Whether to delete thetarget's content initially. (optional, defaulttrue)options.depthbool? Chokidarsdepth(If set, limits how many levels of subdirectories will be traversed). (optional, defaultInfinity)options.transformstring? A module path resolved by node'srequire. (optional, defaultfalse)
notifyNotifyCallback? An optional notification callback.
Returns CloseFunc Returns a close function which cancels active promises and watch mode.
This callback notifies you about various steps, like:
- copy: File or directory has been copied to
target. - remove: File or directory has been removed from
target. - no-delete: No initial deletion of
targets contents. - mirror: Initial copy of all
sourcestotargetdone. - watch: Watch mode has started.
- error: Any error which may occurred during program execution.
Type: Function
Parameters
typestring The type of notification.args...any Event specific variadic arguments.
A cleanup function which cancels all active promises and closes watch mode if enabled.
Type: function
Copy file from source to target.
Parameters
sourcestring A file to be copied.targetstring A destination path where to copy.transformTransformFunc? Optional transformation function.
Returns Promise
Copy a directory from source to target (w/o contents).
Parameters
Returns Promise
Remove a file or directory.
Parameters
fileordirstring The file or directory to remove.
Returns Promise
A custom function which transforms a given file contents and/or target.
Type: function
Parameters
fileFile A file object obtained byfs.readFile.targetstring The destination where to copy thisfile.
Returns (File | {data: File, target: string}) Returns the transformed file and/or renamed target.
Determines whether a provided string contains a glob pattern.
Parameters
strstring The string to test for glob patterns.
Returns number Returns the index of the first glob pattern or -1 if it is not a glob.
Determines the target structure by resolving a given source against a list of base paths.
Parameters
Returns ResolveTargetFunc Returns an source to target resolving function.
A function which resolves a given source to a given target based on list of base paths.
Type: function
Parameters
sourcestring A file or dir to be resolved against a list of base paths.targetstring A destination folder where to append the diff ofsourceandbases.
Returns string Returns an expanded target.
Determine the base paths of sources like:
- files:
foo/bar.txt->foo - directories:
foo/bar/->foo/bar - globs:
foo/*->foo
Parameters
Returns Array<string> Returns the base paths of sources.
Trim quotes of a given string.
Parameters
strstring A string.
Returns string Returns str, but trimmed from quotes like ', ".