From ca50f21fac11da871dc7fda2ee9ffc4c184afa62 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Wed, 19 Feb 2014 23:13:59 -0800 Subject: [PATCH] "middleman init" will create a project in the current directory. Fixes #1181. --- middleman-core/features/cli_init.feature | 26 +++++++++++++------ middleman-core/lib/middleman-core/cli/init.rb | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/middleman-core/features/cli_init.feature b/middleman-core/features/cli_init.feature index fc84cc08..d6d5b4b4 100644 --- a/middleman-core/features/cli_init.feature +++ b/middleman-core/features/cli_init.feature @@ -15,19 +15,29 @@ Feature: Middleman CLI | source/javascripts/all.js | | source/stylesheets/all.css | | source/stylesheets/normalize.css | - + + Scenario: Create a new project in the current directory + Given a directory named "MY_PROJECT" + When I cd to "MY_PROJECT" + And I run `middleman init` + Then the exit status should be 0 + And the following files should exist: + | Gemfile | + | config.rb | + | source/index.html.erb | + Scenario: Create a new project (alias i) When I run `middleman i MY_PROJECT` Then a directory named "MY_PROJECT" should exist - + Scenario: Create a new project (alias new) When I run `middleman new MY_PROJECT` Then a directory named "MY_PROJECT" should exist - + Scenario: Create a new project (alias n) When I run `middleman n MY_PROJECT` Then a directory named "MY_PROJECT" should exist - + Scenario: Create a new project with Rack When I run `middleman init MY_PROJECT --rack` Then a directory named "MY_PROJECT" should exist @@ -36,7 +46,7 @@ Feature: Middleman CLI | config.rb | | config.ru | | Gemfile | - + Scenario: Create a new HTML5 project When I run `middleman init MY_PROJECT --template=html5` Then a directory named "MY_PROJECT" should exist @@ -54,7 +64,7 @@ Feature: Middleman CLI | layouts/layout.erb | | humans.txt | | js/main.js | - + Scenario: Create a new HTML5 project with Rack When I run `middleman init MY_PROJECT --rack --template=html5` Then a directory named "MY_PROJECT" should exist @@ -63,7 +73,7 @@ Feature: Middleman CLI | config.rb | | config.ru | | Gemfile | - + Scenario: Create a new Mobile HTML5 project When I run `middleman init MY_PROJECT --template=mobile` Then a directory named "MY_PROJECT" should exist @@ -79,7 +89,7 @@ Feature: Middleman CLI | index.html | | humans.txt | | js/libs/respond.min.js | - + Scenario: Create a new Mobile HTML5 project with Rack When I run `middleman init MY_PROJECT --rack --template=mobile` Then a directory named "MY_PROJECT" should exist diff --git a/middleman-core/lib/middleman-core/cli/init.rb b/middleman-core/lib/middleman-core/cli/init.rb index 6f61a080..c96e29b4 100644 --- a/middleman-core/lib/middleman-core/cli/init.rb +++ b/middleman-core/lib/middleman-core/cli/init.rb @@ -43,7 +43,7 @@ module Middleman::Cli :desc => 'Skip Git ignores and keeps' # The init task # @param [String] name - def init(name) + def init(name = '.') key = options[:template].to_sym unless ::Middleman::Templates.registered.has_key?(key) raise Thor::Error.new "Unknown project template '#{key}'"