UNPKG

@neodx/vfs

Version:

Simple virtual file system - working dir context, lazy changes, different modes, integrations and moreover

52 lines (48 loc) 1.34 kB
'use strict'; var glob$1 = require('@neodx/glob'); var std = require('@neodx/std'); var createVfsPlugin = require('../_internal/create-vfs-plugin-1jK9qNm1.cjs'); var plugins_scan = require('./scan.cjs'); function glob() { return createVfsPlugin.createVfsPlugin('glob', vfs => { async function globImpl(globOrParams, params) { return await globVfs( vfs, Array.isArray(globOrParams) || std.isTypeOfString(globOrParams) ? { ...params, glob: globOrParams } : globOrParams ); } vfs.glob = globImpl; return vfs; }); } async function globVfs( vfs, { glob, ignore, timeout, signal, log = vfs.log.child('glob'), maxDepth } ) { const cache = plugins_scan.createScanVfsCache(); return await glob$1.walkGlob(glob, { timeout, ignore, signal, log, async reader({ path, isIgnored, isMatched, signal }) { if (await vfs.isFile(path)) return isMatched(path) ? [''] : []; return await plugins_scan.scanVfs(vfs, { path, cache, signal, maxDepth, filter: ({ relativePath }) => isMatched(relativePath), barrier: ({ relativePath }) => isIgnored(relativePath) }); } }); } exports.glob = glob; exports.globVfs = globVfs; //# sourceMappingURL=glob.cjs.map