Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Developing

Drew Folta edited this page Jun 17, 2013 · 3 revisions

Developing the Locator

Here are some details about the locator code itself.

Guidelines and Licensing

See the CONTRIBUTE.md file and LICENSE.txt file for information.

Code Organization

  • _fileQueue is a queue of file events
    • value in queue is specifically designed to be full path, which makes watch() easy to implement
  • _processFileQueue() returns a promise fulfilled when the queue is empty
    • will also process the bundleUpdated queue
  • _onFile() handles each file
    • registers the file in the bundle
    • calls all plugins that handle file events
    • determines if the file is a resource (matches a rule in the ruleset)
    • queues up a bundleUpdated event
  • _onResource() handles each resource
    • registers the resource in the bundle
    • calls all plugins that handle resource events
    • queues up a bundleUpdated event

Since the file events have a full path, we need the following as support:

  • _makeBundle(path) to create a bundle, if it doesn't already exist
  • _getBundleNameByPath(path) to determine the bundle name from a path

Problems and Gotchas

  • making watch() easy to implement affected how rest of code (queues/methods) was organized
  • keeping track of which directories belong to which bundles is unfortunately a bit tricky
  • whether or not the build directory should be watched has subtle implications
  • it's expected that the application code path (basically: set of plugins used) is the same in production as develop, despite the fact that no files are created by plugins in production (because they're made during a build step prior to deploying to production)
Clone this wiki locally