Repositorio del curso CCOM4030 el semestre B91 del proyecto Paz para la Mujer

tape 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env node
  2. var resolveModule = require('resolve').sync;
  3. var resolvePath = require('path').resolve;
  4. var parseOpts = require('minimist');
  5. var glob = require('glob');
  6. var opts = parseOpts(process.argv.slice(2), {
  7. alias: { r: 'require' },
  8. string: 'require',
  9. default: { r: [] }
  10. });
  11. var cwd = process.cwd();
  12. if (typeof opts.require === 'string') {
  13. opts.require = [opts.require];
  14. }
  15. opts.require.forEach(function (module) {
  16. if (module) {
  17. /* This check ensures we ignore `-r ""`, trailing `-r`, or
  18. * other silly things the user might (inadvertently) be doing.
  19. */
  20. require(resolveModule(module, { basedir: cwd }));
  21. }
  22. });
  23. opts._.forEach(function (arg) {
  24. // If glob does not match, `files` will be an empty array.
  25. // Note: `glob.sync` may throw an error and crash the node process.
  26. var files = glob.sync(arg);
  27. if (!Array.isArray(files)) {
  28. throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
  29. }
  30. files.forEach(function (file) {
  31. require(resolvePath(cwd, file));
  32. });
  33. });
  34. // vim: ft=javascript