Created
November 10, 2011 18:32
-
-
Save tal/1355682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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