Class: Bridgetown::Commands::Plugins::CD
- Inherits:
-
Bridgetown::Command
- Object
- Samovar::Command
- Bridgetown::Command
- Bridgetown::Commands::Plugins::CD
- Includes:
- ConfigurationOverridable
- Defined in:
- bridgetown-core/lib/bridgetown-core/commands/plugins.rb
Instance Method Summary collapse
-
#call ⇒ Object
This is super useful if you want to copy files out of plugins to override.
Methods included from ConfigurationOverridable
#configuration_with_overrides, include_options
Methods inherited from Bridgetown::Command
Instance Method Details
#call ⇒ Object
This is super useful if you want to copy files out of plugins to override.
Example: bridgetown plugins cd AwesomePlugin/layouts cp -r * $BRIDGETOWN_SITE/src/_layouts
Now all the plugin’s layouts will be in the site repo directly.
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'bridgetown-core/lib/bridgetown-core/commands/plugins.rb', line 237 def call # rubocop:disable Metrics = configuration_with_overrides(@options) .run_initializers! context: :static directive = path.split("/") unless directive[1] Bridgetown.logger.warn("Oops!", "Your command needs to be in the <origin/dir> format") return end manifest = .source_manifests.find do |source_manifest| source_manifest.origin.to_s == directive[0] end if manifest.respond_to?(directive[1].downcase) dir = manifest.send(directive[1].downcase) Bridgetown.logger.info("Opening the #{dir.green} folder for " \ "#{manifest.origin.to_s.cyan}…") Bridgetown.logger.info("Type #{"exit".yellow} when you're done to " \ "return to your site root.") puts Dir.chdir dir do ENV["BRIDGETOWN_SITE"] = .root_dir system ENV.fetch("SHELL", "/bin/sh") end puts Bridgetown.logger.info("Done!", "You're back in #{Dir.pwd.green}") else Bridgetown.logger.warn("Oops!", "I wasn't able to find the " \ "#{directive[1]} folder for #{directive[0]}") end end |