Skip to content

Instantly share code, notes, and snippets.

@janjongboom
Created January 4, 2016 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janjongboom/975d7fa04813d1713436 to your computer and use it in GitHub Desktop.
Save janjongboom/975d7fa04813d1713436 to your computer and use it in GitHub Desktop.
Find by filename Cloud9 plugin
define(function(require, exports, module) {
main.consumes = ["Plugin", "find"];
main.provides = ["fif"];
return main;
function main(options, imports, register) {
var Plugin = imports.Plugin;
var find = imports.find;
var plugin = new Plugin('Yolo', main.consumes);
plugin.on('load', () => {
// can use wildcards here btw
find.findFiles({ pattern: 'bla.json' }, (err, stdout) => {
if (err) return console.error('findFiles failed', err);
var files = [];
stdout.on('data', data => {
// for some reason every line has a colon (:) on the end...
files = files.concat(data.split('\n').filter(f=>!!f).map(f=>f.replace(/:$/, '')));
});
stdout.on('end', () => console.log(files));
});
});
register(null, {
"fif": plugin
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment