Constructor
# new FSDir(path)
Parameters:
Name | Type | Description |
---|---|---|
path |
string | valid filesystem path string |
Classes
Members
Methods
# async copyTo(targetDir)
Recursively copy current directory to the target dir
Parameters:
Name | Type | Description |
---|---|---|
targetDir |
Directory in which will be copy current |
# dirents() → {FSAsyncIterable.<Dirent>}
Return async iterator which iterates all dirents in dir.
Chaining map, filter and forEach
operators available. toArray operator can be used for resulting chain to array.
FSAsyncIterable.<Dirent>
# files() → {FSAsyncIterable}
Return async iterator which iterates all files in dir. Chaining map, filter and forEach
operators available. toArray operator can be used for resulting chain to array.
# async mkdir(recursive)
Asynchronously creates a directory.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
recursive |
false | if recursive is true, the first directory path created |
# async moveTo(targetDir)
Moves diretory to the new path
Parameters:
Name | Type | Description |
---|---|---|
targetDir |
target directory |
moved direrectory
# subdirs(recursive) → {FSAsyncIterable}
Return async iterator wich iterates each subdirs. Chaining map, filter and forEach
operators available. toArray operator can be used for resulting chain to array.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
recursive |
false | if true returns each subdir of any deep |
Example
const { cwd } = require('fstb');
cwd
.node_modules()
.asDir()
.subdirs(true)
.map(async dir => dir.fspath['package.json']().asFile())
.filter(async package_json => await package_json.isReadable())
.map(async package_json => await package_json.read.json())
.forEach(async content => console.log(`${content.name}@${content.version}`));
# async totalSize()
Compute total size of this directory.
Example
console.log(
'Total size of node_modules is ' +
Math.floor(
(await cwd
.node_modules()
.asDir()
.totalSize()) /
1024 /
1024
) +
' MBytes'
);