Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/valiquire
Validates that all require statements in a project point to an existing path and are correctly cased.
https://github.com/thlorenz/valiquire
Last synced: about 1 month ago
JSON representation
Validates that all require statements in a project point to an existing path and are correctly cased.
- Host: GitHub
- URL: https://github.com/thlorenz/valiquire
- Owner: thlorenz
- License: mit
- Created: 2012-12-10T23:13:34.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-30T04:04:28.000Z (over 10 years ago)
- Last Synced: 2024-11-02T01:42:02.625Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 313 KB
- Stars: 20
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# valiquire [![build status](https://secure.travis-ci.org/thlorenz/valiquire.png)](http://travis-ci.org/thlorenz/valiquire)
Validates that all require statements in a project point to an existing path and are correctly cased.
![screenshot](https://raw.github.com/thlorenz/valiquire/master/assets/screenshot.jpg)
*screenshot condensed for brevity*
## Installation
`npm -g install valiquire`
## Usage
### From root of project
`valiquire .`
### Or from anywhere
`valiquire /path/to/project`
### Redirecting requires
In some scenarios, the require statements aren't resolvable by the nodejs `require` as is.
As an example this could be the case when using [browserify]() either because modules were aliased or shimmed via
[browserify-shim]().In these cases we'd like to either tell valiquire where to find the modules and/or to ignore them. In order to do this,
we simply create a module that exports a redirect function and then specify it as the `--redirect` option.#### Example:
The below redirect function ignores the `generated-later.json` file and redirects valiquire to the client side vendor
libraries```js
'use strict';
var path = require('path')
, vendorDirectory = path.join(__dirname, 'public', 'js', 'vendor')
, browserModules = [ 'jquery', 'jquery.ui', 'd3'];module.exports = function redirect(request) {
// tell valiquire to ignore 'generated-later.json' since it doesn't get generated until the server starts
if (~request.indexOf('generated-later.json')) return null;// tell valiquire to find all browser modules in the vendor directory
if(~browserModules.indexOf(request)) return path.join(vendorDirectory, request);
// all others we don't redirect
return request;
};
```Assuming we saved this file under `valiquire-redirect.js` in the current folder, we can use it when running valiquire as
follows:➜ valiquire . --redirect valiquire-redirect.js