legacy.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*global describe before it */
  2. var spawn = require('child_process').spawn;
  3. var assert = require('assert');
  4. var generators = require('..');
  5. // Helpers
  6. // Install an npm package
  7. function install() {
  8. var pkgs = Array.prototype.slice.call(arguments);
  9. if (!pkgs.length) {
  10. throw new Error('Missing package');
  11. }
  12. return function (done) {
  13. console.error('... Install pkgs ...', pkgs.join(' '));
  14. var npm = spawn('npm', ['install'].concat(pkgs));
  15. npm.stdout.pipe(process.stdout);
  16. npm.stderr.pipe(process.stdout);
  17. npm.on('exit', function (code) {
  18. done(code ? new Error('Error installing ' + pkgs.join(' ') + ' (code: ' + code + ')') : null);
  19. });
  20. return npm;
  21. };
  22. }
  23. function expects(lookup, ln) {
  24. return function() {
  25. var env = generators();
  26. env.prefix('yeoman-');
  27. assert.equal(env.namespaces().length, 0);
  28. env.lookup(lookup);
  29. assert.equal(env.namespaces().length, ln);
  30. };
  31. }
  32. describe.skip('Legacy support', function () {
  33. // disable timeout
  34. this.timeout(0);
  35. // on github
  36. before(install('mklabs/yeoman-jekyll'));
  37. before(install('mklabs/generators#generator-backbone'));
  38. // on npm
  39. // before(install('yeoman-coffeebone', 'yeoman-startr', 'yeoman-wordpress', 'yeoman-bootstrap-less'));
  40. it('lookup *:*', expects('*:*', 9));
  41. it('lookup generator-backbone:*', expects('generator-backbone:*', 6));
  42. it('lookup generator-backbone:all', expects('generator-backbone:all', 1));
  43. it('lookup yeoman-jekyll:*', expects('yeoman-jekyll:*', 3));
  44. it('lookup generator-backbone:*', expects('generator-backbone:*', 6));
  45. it('lookup yeoman-jekyll:*', function () {
  46. var env = generators();
  47. env.prefix('yeoman-*');
  48. env.prefix('generator-*');
  49. env.lookup('*:*');
  50. assert.deepEqual(env.namespaces(), [
  51. 'backbone:all',
  52. 'backbone:app',
  53. 'backbone:collection',
  54. 'backbone:model',
  55. 'backbone:router',
  56. 'backbone:view',
  57. 'jekyll:gruntfile',
  58. 'jekyll',
  59. 'jekyll:post'
  60. ]);
  61. });
  62. });