webtask-require-version
Override require
so you can test your webtask.io scripts.
Install
npm install webtask-require-version
Usage
webtask.io only allows specific versions of modules to be used. When writing my webtasks I wanted to test against those same specific versions (mocking depedencies manually). This module does that by overriding require
to make the require('module@x.y.z')
syntax valid.
your-webtask.js
var request = var qs = var _ = module { // Use request, qs, and lodash in your webtask}
test.js
// This overrides the default `require` // Your webtask can now use use requires like require('request@2.56.0')var webtask = // Other requires will still work { // Test your webtask }
What happens if that version is not installed locally?
webtask-require-version
will throw an error if you try to require a module that does not match based on the semver ^
operator. It will also log a warning if semver
does match but the versions dont match exactly. This warning can be suppressed by using NODE_ENV=production
.
Contributing
This is written in ES6 and compiled to ES5 using babel
. The code you require will come from the lib/
directory which gets compiled from src/
before each npm publish
.
Tests
npm test
License
MIT