Created
January 4, 2016 19:49
-
-
Save janjongboom/975d7fa04813d1713436 to your computer and use it in GitHub Desktop.
Find by filename Cloud9 plugin
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
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