I am trying to write a glob pattern that will search for intellij binaries (roughly), but not search inside C:\Windows since there will not likely be any in there. I've added a bunch of minimatch examples that seem to work as intended, but the glob.sync is not finding the file. Any help is greatly appreciated!
var minimatch = require("minimatch")
var globSync = require('glob').sync
const FILE_THAT_EXISTS = 'C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.1/bin/idea64.exe';
const globPattern = `C:/!(Windows)/JetBrains/IntelliJ*/bin/idea64.exe`;
console.log(minimatch("C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.1/bin/idea64.exe", globPattern))
console.log(minimatch("C:/Program Files (x86)/JetBrains/IntelliJ IDEA 2019.1.1/bin/idea64.exe", globPattern))
console.log(minimatch("C:/Windows/JetBrains/IntelliJ IDEA 2019.1.1/bin/idea64.exe", globPattern))
console.log(minimatch("C:/Software/JetBrains/IntelliJ IDEA 2019.1.1/bin/idea64.exe", globPattern))
console.log(minimatch(FILE_THAT_EXISTS, globPattern));
console.log('\n')
const globResults = globSync(globPattern, {})
console.log(`glob results:`)
console.log(globResults);
console.log('\n')
// Verify that file actually exists:
var fs = require('fs');
try {
fs.accessSync(FILE_THAT_EXISTS)
console.log('file found');
} catch (e) {
console.log('file NOT found')
console.error(e)
}
output of this script:
true
true
false
true
true
glob results:
[]
file found
I expect that executable to be listed in the array of globResults, of course.
This ended up being what I wanted: