Skip to content

Instantly share code, notes, and snippets.

@tal
Created November 10, 2011 18:32
Show Gist options
  • Select an option

  • Save tal/1355682 to your computer and use it in GitHub Desktop.

Select an option

Save tal/1355682 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'fileutils'
require 'pathname'
def system(*args)
puts(" ++ #{args.join(' ')}")
Kernel.system(*args)
end
def notify(msg,level=2)
case level
when 1
msg = "#{msg}\n#{msg.length*'='}"
end
puts msg
end
notify("Updating modules")
unless system("npm --registry=http://jsregistry.qa.ec2.gilt.com/registry/_design/app/_rewrite --dev install")
exit(false)
end
args = ARGV.dup
if args.include?('--')
paths = args.slice![args.index('--')..-1]
paths.shift
paths_arg = paths.join(' ')
end
path_arg ||= args.shift
path_arg = nil if path_arg =~ /^-/
path_arg ||= 'public/javascripts'
targetdir = Pathname(path_arg)
FileUtils.mkdir_p(targetdir)
Dir['node_modules/*/src'].each do |dir|
name = dir.match(/node_modules\/(.+)\/src$/)[1]
cmd = "cp -r '#{dir}/' '#{targetdir.join(name)}/'"
notify("Copying #{name}")
system(cmd)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment