Sha256: 0e65a1feea622b075fca7e03e260c76bb00fa45099ac2a20bdafa07583cdf529
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require_relative "common" module Grundler module Commands class Remove include Common def initialize(cli, packages, json_writer) super(cli) unless File.exist?(Grundler::LOCKFILE_PATH) puts "No #{Grundler::LOCKFILE_PATH} file found!" return end if packages.empty? puts "Must specify a package name!" return end json_writer.remove(delete(packages)) end private def delete(packages) packages.each do |package| puts "Removing #{package}" FileUtils.rm "#{@cli.nodule_path}/#{package}.js" if File.exist?("#{@cli.nodule_path}/#{package}.js") remove_directory_if_empty(package) end packages.map { |package| [package, package] }.to_h end def remove_directory_if_empty(package) dirname = File.dirname("#{@cli.nodule_path}/#{package}.js") FileUtils.rm_rf dirname if Dir.exist?(dirname) && Dir.empty?(dirname) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grundler-0.1.0 | lib/grundler/commands/remove.rb |