locator
locator copied to clipboard
locatorObj.ready could be a promise fulfilled after parseBundle() is done
// locator initialization
var locator = new Locator({
buildDirectory: 'build'
});
locator.plug(pluginOne())
.plug(pluginTwo())
.plug(pluginThree())
.parseBundle(__dirname, {});
locator.ready.then(function(have) {
// do something...
});
this will facilitate passing locator instance around into different components that requires filesystem abstraction and let them know when locator is ready to be used.
related to modown trello card 203
I will also argue that the __dirname
passed into parseBundle
should be a property of the instance since we don't expect parseBundle to be called twice for a locator instance.
locatorObj.parseBundle() already returns the then
. is a getter needed?
// current api
var locator = new Locator({
buildDirectory: 'build'
});
var ready = locator.plug(pluginOne())
.plug(pluginTwo())
.plug(pluginThree())
.parseBundle(__dirname, {});
// the "then" function
ready(function(have) {
// do something...
});
Early on while developing the locator we were uncertain if parseBundle()
would be called multiple times. Since now it's not intended to be, and instead is intended to be called once at the "root" directory it should perhaps be called parseAppRoot()
or parseRootBundle()
.
@drewfish that sounds good (or maybe just parse, or exec, or something). also moving options from the parse method to the constructor where it makes sense, and making available some metadata available as @caridy suggests
when can we get this rolling?