This package has been deprecated

Author message:

This package is no longer maintained.

webtask-require-version

1.0.1 • Public • Published

webtask-require-version

Override require so you can test your webtask.io scripts.

NPM Build Status js-standard-style

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 = require('request@2.56.0')
var qs = require('qs@3.1.0')
var _ = require('lodash@3.9.3')
 
module.exports = function (ctx, cb) {
  // Use request, qs, and lodash in your webtask
}

test.js

// This overrides the default `require`
require('webtask-require-version')
 
// Your webtask can now use use requires like require('request@2.56.0')
var webtask = require('./your-webtask')
 
// Other requires will still work
require('tape')(function (t) {
  // Test your webtask
  webtask(context, function (err, data) {
    t.equal(data, expected)
    t.end();
  })
})

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

Package Sidebar

Install

npm i webtask-require-version

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • lukekarrys