项目原始demo,不改动
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir Pull Requests.

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. };