Created
February 5, 2015 14:14
-
-
Save mikemaccana/fe5c1a83bcbdc0157534 to your computer and use it in GitHub Desktop.
Make a sublime-project file that shows only private modules under 'node_modules'
This file contains hidden or 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
#!/usr/bin/env node | |
var log = console.log.bind(console); | |
var fs = require('fs'), | |
path = require('path'), | |
jsonFile = require('jsonfile') | |
require('es6-shim'); | |
var moduleDirs = fs.readdirSync('node_modules').filter(function (file) { | |
return fs.statSync(path.join('node_modules', file)).isDirectory(); | |
}); | |
var includeDirs = []; | |
moduleDirs.forEach(function(moduleDir){ | |
var packageJSON = path.join('node_modules', moduleDir, 'package.json') | |
if ( fs.existsSync(packageJSON) ) { | |
var packageManifest = jsonFile.readFileSync(packageJSON) | |
if ( packageManifest.private ) { | |
log('private module', moduleDir) | |
includeDirs.push(moduleDir) | |
} | |
} | |
}) | |
var sublimeProjectFile = { | |
"folders": | |
[ | |
{ | |
"path": "." | |
}, | |
{ | |
"path": "node_modules", | |
"folder_include_patterns": includeDirs, | |
} | |
] | |
} | |
jsonFile.writeFileSync('myproject.sublime-project', sublimeProjectFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment