Created
November 2, 2012 06:14
-
-
Save twolfson/3999027 to your computer and use it in GitHub Desktop.
globstar-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load in glob and fs | |
var glob = require('glob'), | |
fs = require('fs'); | |
// Create a test directory | |
try { fs.mkdirSync('src'); } catch (e) {} | |
// Create a nested directory | |
try { fs.mkdirSync('src/nested'); } catch (e) {} | |
// Create a .js file in src and one in nested | |
fs.writeFileSync('src/src.js', 'console.log("1");', 'utf8'); | |
fs.writeFileSync('src/nested/nested.js', 'console.log("2");', 'utf8'); | |
// Find the items via globstar on file | |
var pattern = 'src/**.js', | |
matchedFiles = glob.sync(pattern); | |
// Log the results | |
console.log('globstar on file results: ', matchedFiles); | |
// Find the items via globstar in path | |
var pattern = 'src/**/*.js', | |
matchedFiles = glob.sync(pattern); | |
// Log the results | |
console.log('globstar in path results: ', matchedFiles); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("2"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "globstar-test", | |
"version": "0.0.0", | |
"description": "Test functionality of globstar", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Todd Wolfson <todd@twolfson.com>", | |
"license": "MIT", | |
"dependencies": { | |
"glob": "~3.1.14" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("1"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment