harp.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. var nixt = require('nixt')
  2. var path = require('path')
  3. var fs = require('fs-extra')
  4. var should = require('should')
  5. var harp = require('../')
  6. var exec = require("child_process").exec
  7. describe("harp init", function() {
  8. var outputPath = path.join(__dirname, "out/harp")
  9. beforeEach(function(done){
  10. fs.remove(outputPath, function(err){
  11. fs.mkdirp(outputPath, done)
  12. })
  13. })
  14. it("downloads the default boilerplate if it's not set", function(done) {
  15. this.timeout(10000);
  16. nixt()
  17. .run('node ./bin/harp init ./test/out/harp') // Tests don't work when this has a platform-specific path passed in, but it does work
  18. // .run('node .' + path.sep + 'bin' + path.sep + 'harp init ' + outputPath)
  19. // .stdout(/Downloading.*harp-boilerplates\/default/)
  20. // .stdout(/Initialized project at \test/out\/harp/)
  21. .end(function () {
  22. fs.existsSync(path.join(outputPath, '404.jade')).should.not.be.false
  23. fs.existsSync(path.join(outputPath, '_layout.jade')).should.not.be.false
  24. fs.existsSync(path.join(outputPath, 'index.jade')).should.not.be.false
  25. fs.existsSync(path.join(outputPath, 'main.less')).should.not.be.false
  26. done()
  27. })
  28. })
  29. it("defaults to the harp-boilerplates github org when given a shorthand pattern", function(done) {
  30. this.timeout(10000);
  31. nixt()
  32. .run('node ./bin/harp init ./test/out/harp -b hb-start')
  33. // .stdout(/Downloading.*harp-boilerplates\/hb-start/)
  34. .end(function () {
  35. fs.existsSync(path.join(outputPath, 'public', 'index.jade')).should.not.be.false
  36. fs.existsSync(path.join(outputPath, 'README.md')).should.not.be.false
  37. done()
  38. })
  39. })
  40. it("honors -b option when given a user/repo pattern", function(done) {
  41. this.timeout(10000);
  42. nixt()
  43. .run('node ./bin/harp init ./test/out/harp -b zeke/harp-sample')
  44. // .stdout(/Downloading.*zeke\/harp-sample/)
  45. .end(function () {
  46. fs.existsSync(path.join(outputPath, 'README.md')).should.not.be.false
  47. fs.existsSync(path.join(outputPath, 'index.jade')).should.not.be.false
  48. done()
  49. })
  50. })
  51. it("doesn't overwrite an existing directory", function(done) {
  52. nixt()
  53. .run('node ./bin/harp init ./test/out/harp')
  54. .end(function() {
  55. nixt()
  56. .run('node ./bin/harp harp init ./test/out/harp -b hb-default-sass')
  57. .end(function() {
  58. should.not.exist(fs.exists(path.join(outputPath, 'main.sass')))
  59. done()
  60. })
  61. })
  62. })
  63. after(function(done){
  64. exec("rm -rf " + outputPath, function() {
  65. done();
  66. })
  67. })
  68. })