Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created November 2, 2012 06:14
Show Gist options
  • Save twolfson/3999027 to your computer and use it in GitHub Desktop.
Save twolfson/3999027 to your computer and use it in GitHub Desktop.
globstar-test
/node_modules
// 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);
console.log("2");
{
"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"
}
}
console.log("1");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment