micromatch / glob-fs

file globbing for node.js. speedy and powerful alternative to node-glob. This library is experimental and does not work on windows!
http://jonschlinkert.github.io/glob-fs
MIT License
55 stars 17 forks source link

readdirSync is returning files from wrong path #31

Open georgejecook opened 5 years ago

georgejecook commented 5 years ago

given

`` debug(processing files at path ${process.cwd()} `);

let fileProcessor = new FileProcessor(this._config);
fileProcessor.rootPath = process.cwd();
let files = glob.readdirSync(this._config.globPattern);
files.forEach( (file) => {```

where the process.cwd() is /Users/georgecook/Documents/h7ci/hope/opensource/navSpike/build/.roku-deploy-staging

and a globPattern of **/*.brs

I find the returned files have a path of .roku-deploy-staging/components/Framework/Core/BaseAggregateView.brs - this is wrong! that folder doesn't even exist - it's as if readdirSync is running the glob against build instead of build.roku-deploy-staging

I'll have to stop using this package if I can't get around this, as it's breaking my tools.

georgejecook commented 5 years ago

note - I used cwd flag as per https://github.com/micromatch/glob-fs/issues/16 - still does the wrong behaviour, acting as if it's one level up

georgejecook commented 5 years ago

it seems the problem is specifically folders which start with a . - it simply ignores them, which renders this unusable.

AraHaan commented 3 years ago

That is by default you can disable that however.

AraHaan commented 3 years ago

I use this in my github action and for some reason it's not finding files with this glob pattern **/*.csproj.

const globfs = require("glob-fs")()

class Action {

    constructor() {
    }

    // snip some other unrelated stuff.

    run() {
        // unrelated: checks if input is not a glob then call _run_internal
        // otherwise call _run_internal after resetting "projectFile", and
        // "versionFile" to the relative path of the file found by the glob pattern.
        globfs.readdirSync('**/*.csproj').forEach(function (file) {
            this.projectFile = file.relative
            this.versionFile = file.relative
            this._run_internal()
        })
    }
}

new Action().run()

However for some reason it skips everything in the forEach.