1#!/usr/bin/ruby 2 3require 'fileutils' 4 5if ARGV.size != 1 6 puts "usage: #{File.basename $0} <codemirror-repo-path>" 7 exit 1 8end 9 10def verify_code_mirror_repository_path(path) 11 if !File.directory? path 12 puts "ERROR: Provided CodeMirror path is not a directory." 13 exit 1 14 end 15 16 Dir.chdir(path) do 17 results = `git config --list | grep 'marijnh/CodeMirror\.git'` 18 if $?.exitstatus != 0 || results.split("\n").empty? 19 puts "ERROR: Provided CodeMirror path does not appear to be a CodeMirror checkout." 20 exit 1 21 end 22 end 23end 24 25code_mirror_repository_path = File.expand_path ARGV[0] 26verify_code_mirror_repository_path code_mirror_repository_path 27 28web_inspector_user_interface_path = File.expand_path File.join(File.dirname(__FILE__), "../UserInterface") 29web_inspector_code_mirror_resources_path = File.join web_inspector_user_interface_path, "/External/CodeMirror" 30 31CODE_MIRROR_FILES_TO_COPY = %w( 32 addon/comment/comment.js 33 addon/display/placeholder.js 34 addon/edit/closebrackets.js 35 addon/edit/matchbrackets.js 36 addon/mode/overlay.js 37 addon/runmode/runmode.js 38 addon/search/searchcursor.js 39 lib/codemirror.css 40 lib/codemirror.js 41 mode/clojure/clojure.js 42 mode/coffeescript/coffeescript.js 43 mode/css/css.js 44 mode/htmlmixed/htmlmixed.js 45 mode/javascript/javascript.js 46 mode/livescript/livescript.js 47 mode/sass/sass.js 48 mode/sql/sql.js 49 mode/xml/xml.js 50) 51 52all_success = true 53 54CODE_MIRROR_FILES_TO_COPY.each do |subpath| 55 from_path = File.join code_mirror_repository_path, subpath 56 to_path = File.join web_inspector_code_mirror_resources_path, File.basename(subpath) 57 begin 58 puts "Copying #{File.basename(subpath)}..." 59 FileUtils.cp from_path, to_path 60 rescue Exception => e 61 puts "WARNING: #{e}" 62 all_success = false 63 end 64end 65 66exit all_success ? 0 : 1 67