Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

index.js 1013B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. const path = require('path');
  3. const pathKey = require('path-key');
  4. const npmRunPath = options => {
  5. options = {
  6. cwd: process.cwd(),
  7. path: process.env[pathKey()],
  8. execPath: process.execPath,
  9. ...options
  10. };
  11. let previous;
  12. let cwdPath = path.resolve(options.cwd);
  13. const result = [];
  14. while (previous !== cwdPath) {
  15. result.push(path.join(cwdPath, 'node_modules/.bin'));
  16. previous = cwdPath;
  17. cwdPath = path.resolve(cwdPath, '..');
  18. }
  19. // Ensure the running `node` binary is used
  20. const execPathDir = path.resolve(options.cwd, options.execPath, '..');
  21. result.push(execPathDir);
  22. return result.concat(options.path).join(path.delimiter);
  23. };
  24. module.exports = npmRunPath;
  25. // TODO: Remove this for the next major release
  26. module.exports.default = npmRunPath;
  27. module.exports.env = options => {
  28. options = {
  29. env: process.env,
  30. ...options
  31. };
  32. const env = {...options.env};
  33. const path = pathKey({env});
  34. options.path = env[path];
  35. env[path] = module.exports(options);
  36. return env;
  37. };