From a0a21504177edbbd5cdfe44897847e5148bc9e7d Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Sat, 14 Dec 2013 17:14:10 -0500 Subject: [PATCH] fix up tests to work much better - pull from real github repo - fix strange bug in prepublish task - remove unneeded deps - eliminate any extra console logs when overriding prompt --- .gitignore | 2 +- .travis.yml | 1 - Gulpfile.js | 2 +- lib/commands/add.coffee | 4 ++-- lib/commands/init.coffee | 6 ++++-- package.json | 8 ++++---- test/fixtures/basic | 1 - test/test.coffee | 5 ++--- 8 files changed, 14 insertions(+), 15 deletions(-) delete mode 160000 test/fixtures/basic diff --git a/.gitignore b/.gitignore index 91dfed8..9daa824 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .DS_Store -node_modules \ No newline at end of file +node_modules diff --git a/.travis.yml b/.travis.yml index b9207e5..244b7e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ language: node_js node_js: - - '0.8' - '0.10' diff --git a/Gulpfile.js b/Gulpfile.js index 69d2a59..d8f0f9c 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -2,5 +2,5 @@ var g = require('gulp'), coffee = require('gulp-coffee'); g.task('build', function(){ - g.src('src/**/*.coffee').pipe(coffee({ bare: true })).pipe(g.dest('lib')) + g.src('src/**/*.coffee').pipe(coffee()).pipe(g.dest('lib')) }); diff --git a/lib/commands/add.coffee b/lib/commands/add.coffee index d74b921..6a896bb 100644 --- a/lib/commands/add.coffee +++ b/lib/commands/add.coffee @@ -1,4 +1,4 @@ -require 'shelljs/global' +which = require 'which' exec = require('child_process').exec Base = require '../base' accord = require '../utils/accord' @@ -10,7 +10,7 @@ class Add extends Base accord.call(@, { name: name, url: url, options: opts, cb: cb }) if not @name then return @cb('your template needs a name!') - if not which('git') then return @cb('you need to have git installed') + if not which.sync('git') then return @cb('you need to have git installed') if @name and not @url @url = @name diff --git a/lib/commands/init.coffee b/lib/commands/init.coffee index 7a90319..40f6ad0 100644 --- a/lib/commands/init.coffee +++ b/lib/commands/init.coffee @@ -53,14 +53,16 @@ class Init extends Base @config_values = @options return W.resolve() - console.log '\nplease enter the following information:'.yellow prompt.override = @options prompt.message = '' prompt.delimiter = '' + + if not prompt.override then console.log '\nplease enter the following information:'.yellow + prompt.start() nodefn.call(prompt.get, @config.configure).tap (res) => @config_values = res - console.log('') + if not prompt.override then console.log('') user_after_fn = -> if not @config.before then return W.resolve() diff --git a/package.json b/package.json index 4fcf92a..6814ec1 100644 --- a/package.json +++ b/package.json @@ -15,23 +15,23 @@ "colors": "0.6.x", "optimist": "0.6.x", "indx": "0.0.x", - "shelljs": "0.2.x", "osenv": "0.0.x", "rimraf": "2.x.x", "ncp": "0.4.x", "ejs": "0.8.x", "prompt": "0.2.x", "readdirp": "0.3.x", - "event-stream": "3.x.x", "when": "2.x.x", "sugar": "1.x.x", - "mkdirp": "0.3.x" + "mkdirp": "0.3.x", + "which": "1.0.x" }, "devDependencies": { "mocha": "*", "should": "*", "gulp": "3.x.x", - "gulp-coffee": "1.x.x" + "gulp-coffee": "1.x.x", + "shelljs": "0.2.x" }, "scripts": { "test": "mocha", diff --git a/test/fixtures/basic b/test/fixtures/basic deleted file mode 160000 index 7f01f01..0000000 --- a/test/fixtures/basic +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7f01f0119d3b55c258fc031870a8a9d94c90780a diff --git a/test/test.coffee b/test/test.coffee index fdf6e98..b5afd47 100644 --- a/test/test.coffee +++ b/test/test.coffee @@ -9,7 +9,6 @@ before -> @exec = (cmd) -> exec(cmd, {silent: true}) @$ = path.join(__dirname, '../bin/sprout') - describe 'accord', -> beforeEach -> @@ -72,7 +71,7 @@ describe 'js api', -> it '[init] creates a project template correctly', (done) -> basic_path = path.join(__dirname, 'fixtures/basic') - sprout.add 'foobar', "file:////#{basic_path}", (err, res) -> + sprout.add 'foobar', "https://github.com/jenius/sprout-test-template.git", (err, res) -> should.not.exist(err) testpath = path.join(__dirname, 'testproj') sprout.init 'foobar', testpath, { foo: 'bar' }, (err, res) => @@ -124,7 +123,7 @@ describe 'cli', -> cmd.code.should.be.above(0) it '[init] creates a project template correctly', -> - cmd = @exec("#{@$} add foobar file:////#{path.join(__dirname, 'fixtures/basic')}") + cmd = @exec("#{@$} add foobar https://github.com/jenius/sprout-test-template.git") cmd.code.should.eql(0) testpath = path.join(__dirname, 'testproj') cmd = @exec("#{@$} init foobar #{testpath} --foo bar")