* Processes the provided object. * @private * @template T * @template ItemType * @param {object} options options * @param {string} options.path path * @param {(value: string) => ItemType} options.fromImmutablePath called when context item is an immutable path * @param {(value: string)
(
{
path,
fromImmutablePath,
fromManagedItem,
fromSymlink,
fromFile,
fromDirectory,
reduce
},
callback
)
| 3774 | * @param {(err?: Error | null, result?: T | null) => void} callback callback |
| 3775 | */ |
| 3776 | _readContext( |
| 3777 | { |
| 3778 | path, |
| 3779 | fromImmutablePath, |
| 3780 | fromManagedItem, |
| 3781 | fromSymlink, |
| 3782 | fromFile, |
| 3783 | fromDirectory, |
| 3784 | reduce |
| 3785 | }, |
| 3786 | callback |
| 3787 | ) { |
| 3788 | this.fs.readdir(path, (err, _files) => { |
| 3789 | if (err) { |
| 3790 | if (err.code === class="st">"ENOENT") { |
| 3791 | return callback(null, null); |
| 3792 | } |
| 3793 | return callback(err); |
| 3794 | } |
| 3795 | const files = /** @type {string[]} */ (_files) |
| 3796 | .map((file) => file.normalize(class="st">"NFC")) |
| 3797 | .filter((file) => !/^\./.test(file)) |
| 3798 | .sort(); |
| 3799 | asyncLib.map( |
| 3800 | files, |
| 3801 | (file, callback) => { |
| 3802 | const child = join(this.fs, path, file); |
| 3803 | for (const immutablePath of this.immutablePathsRegExps) { |
| 3804 | if (immutablePath.test(path)) { |
| 3805 | class="cm">// ignore any immutable path for timestamping |
| 3806 | return callback(null, fromImmutablePath(path)); |
| 3807 | } |
| 3808 | } |
| 3809 | for (const immutablePath of this.immutablePathsWithSlash) { |
| 3810 | if (path.startsWith(immutablePath)) { |
| 3811 | class="cm">// ignore any immutable path for timestamping |
| 3812 | return callback(null, fromImmutablePath(path)); |
| 3813 | } |
| 3814 | } |
| 3815 | for (const managedPath of this.managedPathsRegExps) { |
| 3816 | const match = managedPath.exec(path); |
| 3817 | if (match) { |
| 3818 | const managedItem = getManagedItem(match[1], path); |
| 3819 | if (managedItem) { |
| 3820 | class="cm">// construct timestampHash from managed info |
| 3821 | return this.managedItemQueue.add(managedItem, (err, info) => { |
| 3822 | if (err) return callback(err); |
| 3823 | return callback( |
| 3824 | null, |
| 3825 | fromManagedItem(/** @type {string} */ (info)) |
| 3826 | ); |
| 3827 | }); |
| 3828 | } |
| 3829 | } |
| 3830 | } |
| 3831 | for (const managedPath of this.managedPathsWithSlash) { |
| 3832 | if (path.startsWith(managedPath)) { |
| 3833 | const managedItem = getManagedItem(managedPath, child); |
no test coverage detected