File: update-codemirror-resources.rb

package info (click to toggle)
qtwebkit-opensource-src 5.3.2%2Bdfsg-2~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 291,472 kB
  • sloc: cpp: 1,358,084; python: 70,286; ansic: 42,964; perl: 35,474; ruby: 12,229; objc: 9,465; xml: 8,396; asm: 3,866; yacc: 2,397; sh: 1,647; makefile: 644; lex: 644; java: 110
file content (67 lines) | stat: -rwxr-xr-x 1,825 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/ruby

require 'fileutils'

if ARGV.size != 1
  puts "usage: #{File.basename $0} <codemirror-repo-path>"
  exit 1
end

def verify_code_mirror_repository_path(path)
  if !File.directory? path
    puts "ERROR: Provided CodeMirror path is not a directory."
    exit 1
  end

  Dir.chdir(path) do
    results = `git config --list | grep 'marijnh/CodeMirror\.git'`
    if $?.exitstatus != 0 || results.split("\n").empty?
      puts "ERROR: Provided CodeMirror path does not appear to be a CodeMirror checkout."
      exit 1
    end
  end
end

code_mirror_repository_path = File.expand_path ARGV[0]
verify_code_mirror_repository_path code_mirror_repository_path

web_inspector_user_interface_path = File.expand_path File.join(File.dirname(__FILE__), "../UserInterface")
web_inspector_code_mirror_resources_path = File.join web_inspector_user_interface_path, "/External/CodeMirror"

CODE_MIRROR_FILES_TO_COPY = %w(
  addon/comment/comment.js
  addon/display/placeholder.js
  addon/edit/closebrackets.js
  addon/edit/matchbrackets.js
  addon/mode/overlay.js
  addon/runmode/runmode.js
  addon/search/searchcursor.js
  lib/codemirror.css
  lib/codemirror.js
  mode/clojure/clojure.js
  mode/coffeescript/coffeescript.js
  mode/css/css.js
  mode/htmlmixed/htmlmixed.js
  mode/javascript/javascript.js
  mode/less/less.js
  mode/livescript/livescript.js
  mode/sass/sass.js
  mode/sql/sql.js
  mode/xml/xml.js
)

all_success = true

CODE_MIRROR_FILES_TO_COPY.each do |subpath|
  from_path = File.join code_mirror_repository_path, subpath
  to_path = File.join web_inspector_code_mirror_resources_path, File.basename(subpath)
  begin
    puts "Copying #{File.basename(subpath)}..."
    FileUtils.cp from_path, to_path
  rescue Exception => e
    puts "WARNING: #{e}"
    all_success = false
  end
end

exit all_success ? 0 : 1