Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Add support for --path option to install
Browse files Browse the repository at this point in the history
This allows installing Neat into a specific directory.
It's more consistent with Bourbon CLI

Fix #351
  • Loading branch information
Mehdi Lahmam authored and mehlah committed Jul 9, 2016
1 parent 1047d6e commit cc0c1fd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -45,6 +45,12 @@ For command line help, visit our wiki page on Neat’s [command line interface](
neat install
```

**Pro Tip:** You can target installation into a specific directory using the `path` flag:

```bash
neat install --path my/custom/path/
```

4. Import Neat in your stylesheet:

```scss
Expand Down
33 changes: 26 additions & 7 deletions lib/neat/generator.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
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
Expand Down

0 comments on commit cc0c1fd

Please sign in to comment.