Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 754B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var path = require('path');
  3. var resolveFrom = require('resolve-from');
  4. var callerPath = require('caller-path');
  5. module.exports = function (moduleId) {
  6. if (typeof moduleId !== 'string') {
  7. throw new TypeError('Expected a string');
  8. }
  9. var filePath = resolveFrom(path.dirname(callerPath()), moduleId);
  10. // delete itself from module parent
  11. if (require.cache[filePath] && require.cache[filePath].parent) {
  12. var i = require.cache[filePath].parent.children.length;
  13. while (i--) {
  14. if (require.cache[filePath].parent.children[i].id === filePath) {
  15. require.cache[filePath].parent.children.splice(i, 1);
  16. }
  17. }
  18. }
  19. // delete module from cache
  20. delete require.cache[filePath];
  21. // return fresh module
  22. return require(filePath);
  23. };