Dir class port of ruby.
As JavaScript does not support bracket methods, we have a getter and setter instead.
For node js only, does not work inside a browser.
- Dir
- .glob(pattern, options, base_path) →
Array.<string>
|null
- .pwd() →
string
- .chdir(dir)
- .delete(file_name, opts)
- .isExisting(file_name) →
boolean
- .glob(pattern, options, base_path) →
Expands pattern, which is a pattern string or an Array of pattern strings, and returns an array containing the matching filenames.
Param | Type | Description |
---|---|---|
pattern | string | Array.<string> |
|
options | object |
of npm package 'glob' |
base_path | string |
shortcut of options.cwd with higher prio |
Returns the path to the current working directory of this process as a string.
Changes the current working directory of the process to the given string.
When called without an argument, changes the directory to the value of the environment variable HOME, or LOGDIR or the operating systems home directory by API. Throws:
Error
if directory can not be changed
Param | Type |
---|---|
dir | string |
Deletes the named directory.
Param | Type | Default | Description |
---|---|---|---|
file_name | string |
||
opts | Object |
||
opts.recursive | boolean |
false |
If true, perform a recursive directory removal. In recursive mode, operations are retried on failure |
opts.max_retries | boolean |
0 |
If an EBUSY, EMFILE, ENFILE, ENOTEMPTY, or EPERM error is encountered, Node.js retries the operation with a linear backoff wait of retryDelay milliseconds longer on each try. This option represents the number of retries. This option is ignored if the recursive option is not true |
opts.retry_delay | boolean |
100 |
The amount of time in milliseconds to wait between retries. This option is ignored if the recursive option is not true |
Returns true if the named file is a directory, false otherwise.
Param | Type |
---|---|
file_name | string |