Web Inspector: vended backend commands file should be generated as part of the build
[WebKit-https.git] / Source / WebInspectorUI / Scripts / update-codemirror-resources.rb
1 #!/usr/bin/ruby
2
3 require 'fileutils'
4
5 if ARGV.size != 1
6   puts "usage: #{File.basename $0} <codemirror-repo-path>"
7   exit 1
8 end
9
10 def 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
23 end
24
25 code_mirror_repository_path = File.expand_path ARGV[0]
26 verify_code_mirror_repository_path code_mirror_repository_path
27
28 web_inspector_user_interface_path = File.expand_path File.join(File.dirname(__FILE__), "../UserInterface")
29 web_inspector_code_mirror_resources_path = File.join web_inspector_user_interface_path, "/External/CodeMirror"
30
31 CODE_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/less/less.js
47   mode/livescript/livescript.js
48   mode/sass/sass.js
49   mode/sql/sql.js
50   mode/xml/xml.js
51 )
52
53 all_success = true
54
55 CODE_MIRROR_FILES_TO_COPY.each do |subpath|
56   from_path = File.join code_mirror_repository_path, subpath
57   to_path = File.join web_inspector_code_mirror_resources_path, File.basename(subpath)
58   begin
59     puts "Copying #{File.basename(subpath)}..."
60     FileUtils.cp from_path, to_path
61   rescue Exception => e
62     puts "WARNING: #{e}"
63     all_success = false
64   end
65 end
66
67 exit all_success ? 0 : 1