How to use the fast-glob.escapePath function in fast-glob

To help you get started, we’ve selected a few fast-glob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ryanelian / instapack / bin / CopyBuildTool.js View on Github external
const tasks = [];
            const globs = [];
            for (const file of job.files) {
                const absoluteFilePath = upath.join(libraryPath, file);
                const relativeFilePath = upath.relative(libraryPath, absoluteFilePath);
                if (relativeFilePath.startsWith('../')) {
                    Shout_1.Shout.warning(`Copy skip: ${chalk.cyan(file)} is outside library ${chalk.cyan(job.library)} folder!`);
                    continue;
                }
                try {
                    const fileStats = yield fse.lstat(absoluteFilePath);
                    if (fileStats.isFile()) {
                        globs.push(FastGlob.escapePath(relativeFilePath));
                    }
                    else if (fileStats.isDirectory()) {
                        const globbedPath = upath.join(FastGlob.escapePath(relativeFilePath), '**');
                        globs.push(globbedPath);
                    }
                    else {
                        Shout_1.Shout.warning(`Copy skip: ${absoluteFilePath} is neither a file nor a folder?!`);
                    }
                }
                catch (e) {
                    if (FastGlob.isDynamicPattern(relativeFilePath)) {
                        globs.push(relativeFilePath);
                    }
                }
            }
            const assets = yield FastGlob(globs, {
                cwd: libraryPath
            });
            const commonPath = this.findCommonParentFolderPath(assets);
github ryanelian / instapack / bin / CopyBuildTool.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            const libraryPath = upath.join(this.pathFinder.npmFolder, job.library);
            const targetPath = upath.join(this.pathFinder.outputFolderPath, job.destination);
            const tasks = [];
            const globs = [];
            for (const file of job.files) {
                const absoluteFilePath = upath.join(libraryPath, file);
                const relativeFilePath = upath.relative(libraryPath, absoluteFilePath);
                if (relativeFilePath.startsWith('../')) {
                    Shout_1.Shout.warning(`Copy skip: ${chalk.cyan(file)} is outside library ${chalk.cyan(job.library)} folder!`);
                    continue;
                }
                try {
                    const fileStats = yield fse.lstat(absoluteFilePath);
                    if (fileStats.isFile()) {
                        globs.push(FastGlob.escapePath(relativeFilePath));
                    }
                    else if (fileStats.isDirectory()) {
                        const globbedPath = upath.join(FastGlob.escapePath(relativeFilePath), '**');
                        globs.push(globbedPath);
                    }
                    else {
                        Shout_1.Shout.warning(`Copy skip: ${absoluteFilePath} is neither a file nor a folder?!`);
                    }
                }
                catch (e) {
                    if (FastGlob.isDynamicPattern(relativeFilePath)) {
                        globs.push(relativeFilePath);
                    }
                }
            }
            const assets = yield FastGlob(globs, {

fast-glob

It's a very fast and efficient glob library for Node.js

MIT
Latest version published 1 year ago

Package Health Score

83 / 100
Full package analysis