
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
The locator gives semantic meaning to files on the filesystem. It does this with a set of "rules" that describes how each file path should be interpreted. In addition it groups files into "bundles". (Each bundle is usually an NPM module, but not always.)
The locator doesn't interpret the semantic meaning of the files. It is up to the user to understand and use the semantic meanings associated with the files.
package.json (for those bundles that are NPM modules)Install using npm:
$ npm install locator
In your app's package.json:
{
"dependencies": {
...
"mojito": "*",
...
},
"locator": {
"rulesets": "mojito/locator-rulesets"
}
}
In your app's package.json:
{
"locator": {
"rulesets": "locator-rulesets"
}
}
A new locator-rulesets.js file which defines how to add semantic meaning to filesystem paths:
module.exports = {
// nameKey defaults to 1
// selectorKey has no default. selector is only used if selectorKey is given
main: {
// we can use this to skip files
_skip: [
/^tests?\b/i
],
// where to find configuration files
configs: {
regex: /^configs\/([a-z_\-\/]+)\.(json|js)$/i
},
// where to find templates
templates: {
regex: /^templates\/([a-z_\-\/]+)(\.([\w_\-]+))?\.[^\.\/]+\.html$/i,
// We use "selectors" because we might use different templates based
// on different circumstances.
selectorKey: 3
},
// where to find CSS files
css: {
regex: /^public\/css\/([a-z_\-\/]+)\.css$/i
}
}
};
Then, in your app.js (or wherever makes sense to you) you can do something like:
var Locator = require('locator');
locator = new Locator();
var resources = locator.parseBundle(__dirname);
// access your "configs/foo.json" configuration file
... resources.configs.foo ...
// access all your templates
Object.keys(resources.templates).forEach(function (templateName) {
var templateResource = resources.templates[templateName];
...
});
In your app's package.json:
{
"name": "usually-a-long-name-for-npm"
"locator": {
"name": "foo"
}
}
By default, locator will select the name of the bundle from the package.json->name entry, but you should be able to specify a custom name by adding a name entry under the locator entry in package.json. This will help to decouple the name of the package from the urls that you will use to fetch those scripts from the client side.
This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.
See the CONTRIBUTING.md file for information on contributing back to Locator.
FAQs
gives semantic meaning to filesystem paths
The npm package locator receives a total of 103 weekly downloads. As such, locator popularity was classified as not popular.
We found that locator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.