File: update-codemirror-resources.rb

package info (click to toggle)
webkit2gtk 2.48.3-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 429,620 kB
  • sloc: cpp: 3,696,936; javascript: 194,444; ansic: 169,997; python: 46,499; asm: 19,276; ruby: 18,528; perl: 16,602; xml: 4,650; yacc: 2,360; sh: 2,098; java: 1,993; lex: 1,327; pascal: 366; makefile: 295
file content (71 lines) | stat: -rwxr-xr-x 1,918 bytes parent folder | download | duplicates (14)
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
68
69
70
71
#!/usr/bin/env 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 'codemirror/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(
  LICENSE
  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
  addon/selection/mark-selection.js
  keymap/sublime.js
  lib/codemirror.css
  lib/codemirror.js
  mode/clike/clike.js
  mode/clojure/clojure.js
  mode/coffeescript/coffeescript.js
  mode/css/css.js
  mode/htmlmixed/htmlmixed.js
  mode/javascript/javascript.js
  mode/jsx/jsx.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