This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 425
Add support for --path
option to install
#459
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,18 @@ class Generator < Thor | |
map ["-v", "--version"] => :version | ||
|
||
desc "install", "Install Neat into your project" | ||
method_options path: :string, force: :boolean | ||
def install | ||
if neat_files_already_exist? | ||
if neat_files_already_exist? && !options[:force] | ||
puts "Neat files already installed, doing nothing." | ||
else | ||
install_files | ||
puts "Neat files installed to neat/" | ||
puts "Neat files installed to #{install_path}/" | ||
end | ||
end | ||
|
||
desc "update", "Update Neat" | ||
method_options path: :string | ||
def update | ||
if neat_files_already_exist? | ||
remove_neat_directory | ||
|
@@ -28,6 +30,7 @@ def update | |
end | ||
|
||
desc "remove", "Remove Neat" | ||
method_options path: :string | ||
def remove | ||
if neat_files_already_exist? | ||
remove_neat_directory | ||
|
@@ -45,16 +48,32 @@ def version | |
private | ||
|
||
def neat_files_already_exist? | ||
File.directory?("neat") | ||
install_path.exist? | ||
end | ||
|
||
def install_files | ||
FileUtils.mkdir_p("neat") | ||
FileUtils.cp_r(all_stylesheets, "neat/") | ||
def install_path | ||
@install_path ||= if options[:path] | ||
Pathname.new(File.join(options[:path], "neat")) | ||
else | ||
Pathname.new("neat") | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. end at 59, 8 is not aligned with if at 55, 24. |
||
end | ||
|
||
def remove_neat_directory | ||
FileUtils.rm_rf("neat") | ||
FileUtils.rm_rf(install_path) | ||
end | ||
|
||
def install_files | ||
make_install_directory | ||
copy_in_scss_files | ||
end | ||
|
||
def make_install_directory | ||
FileUtils.mkdir_p(install_path) | ||
end | ||
|
||
def copy_in_scss_files | ||
FileUtils.cp_r(all_stylesheets, install_path) | ||
end | ||
|
||
def all_stylesheets | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align else with if.