index.js 877 B

12345678910111213141516171819202122232425262728
  1. /*
  2. Copyright (c) 2014 Google Inc. All rights reserved.
  3. Use of this source code is governed by the MIT License, available in this package's LICENSE file
  4. or at http://opensource.org/licenses/MIT.
  5. */
  6. const _ = require('lodash');
  7. const Requizzle = require('./lib/requizzle');
  8. module.exports = function requizzle(options) {
  9. let instance;
  10. if (!options || typeof options !== 'object') {
  11. throw new TypeError('Requizzle\'s options parameter must be a non-null object.');
  12. }
  13. options = _.clone(options);
  14. options.parent = module.parent;
  15. return filepath => {
  16. instance = instance || new Requizzle(options);
  17. return instance.requizzle(filepath);
  18. };
  19. };
  20. module.exports.Requizzle = Requizzle;
  21. // force Node.js to reload this module each time it's required, so module.parent is always correct
  22. delete require.cache[__filename];