Skip to content

Instantly share code, notes, and snippets.

@timcheadle
Created May 6, 2015 17:51
Middleman + Guard + shopify_theme
require 'yaml'
guard :shell do
watch(/source\/(.*)/) { |m| `bundle exec middleman build --clean` }
watch(/build\/(.*)/) do |m|
break if m[0] == 'build/config.yml'
store = ''
if File.exist?('build/config.yml')
config = YAML.load_file('build/config.yml')
store = config[:store]
end
file = Pathname.new(m[0])
if file.exist?
puts "shopify (#{store}): uploading #{m[1]}"
`cd build && bundle exec theme upload #{m[1]}`
else
puts "shopify (#{store}): removing #{m[1]}"
`cd build && bundle exec theme remove #{m[1]}`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment