forked from thesunny/SnapEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guardfile
133 lines (120 loc) · 4.57 KB
/
Guardfile
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Copyright (c) 2012-2013 8098182 Canada Inc. All rights reserved.
# For licensing, see LICENSE.
# More info at https://github.com/guard/guard#readme
spec_location = "spec/javascripts/%s.spec"
# uncomment if you use NerdCapsSpec.js
# spec_location = "spec/javascripts/%sSpec"
all_on_start = false
guard :coffeescript, input: "coffeescripts", output: "javascripts", bare: true, shallow: false, all_on_start: all_on_start
# guard :coffeescript, input: "spec-coffeescripts", output: "spec", bare: true, shallow: false, all_on_start: all_on_start
# # Compiles all the spec-coffeescripts files into the spec directory except for
# # the .coffee script files themselves. This is so that we can work exclusively
# # in the spec-coffeescripts directory to write our specs.
# guard :shell, all_on_start: all_on_start do
# watch(%r{^spec-coffeescripts/(.*)}) do |m|
# path = m[0]
# subpath = m[1]
# # puts m[0]
# # n m[0]
# # n m[0]
# if !File.directory?(path) && File.extname(path) != '.coffee'
# # puts m[1]
# # puts path + " Copy it"
# # pp path, File.join("spec", subpath)
# dest = File.join("spec", subpath)
# dest_dir = File.dirname(dest)
# FileUtils.mkdir_p(dest_dir)
# FileUtils.cp path, dest
# "Copied #{path} to spec"
# # FileUtils.cp_r path, File.join()
# else
# nil
# end
# # dir = File.directory?(path)
# # if !dir
# # FileUtils.copy
# # end
# # path + " has changed"
# end
# end
guard :shell, all_on_start: all_on_start do
watch(%r{^coffeescripts/.*[.]coffee}) do |m|
# output = `bundle exec rake build_dev`
# if $?.to_i == 0
# n "Successfully built build/snapeditor.js", "Dev Build Successful", :success
# else
# n "Please check console for errors", "Build Failed", :failed
# end
dev_output = `bundle exec rake build_dev`
spec_output = `bundle exec rake build_spec`
"-----BUILD DEV-----\n" + dev_output.split("-----")[0] + "\n" +
"-----BUILD SPEC-----\n" + spec_output.split("-----")[0]
# if $?.to_i == 0
# n "Successfully built output/snapeditor_spec.js", "Spec Build Successful", :success
# else
# n "Please check console for errors", "Spec Build Failed", :failed
# end
# output
# output
end
end
# IMPORTANT!
# Suprer Important note! Currently we have to modify guard jasmine to get the
# tests to run. It is expecting specs to look like _spec.js but we use the
# format .spec.js. This is because Wes originally ran guard-jasmine-headless-webkit
# which worked fine with that file naming format.
#
# Kind of sucks and is stupid that these spec files fail to run silently.
#
# # Tests if the file is valid.
# #
# # @param [String] path the file
# # @return [Boolean] when the file valid
# #
# def jasmine_spec?(path)
# path =~ /(_|[.])spec\.(js|coffee|js\.coffee)$/ && File.exists?(path)
# end
# guard 'jasmine',
# all_on_start: all_on_start,
# # server: :none,
# # server: :jasmine_gem,
# server: :none,
# server_mount: '/',
# jasmine_url: 'http://127.0.0.1:3000/jasmine',
# # verbose: true,
# phantomjs_bin: '\\bin\\phantomjs\\phantomjs192\\phantomjs',
# port: 8888 do
# # watch(%r{spec/javascripts\.(js\.coffee|js|coffee)$}) { "spec/javascripts" }
# # watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
# watch(%r{^javascripts/(.+?)\.(js)$}) { |m|
# path = "spec/javascripts/#{m[1]}.spec.#{m[2]}"
# puts "Jasmine spec should run after this for #{path}"
# path
# # TODO:
# # The return value should actually be the specs that are to be run but
# # this doesn't seem to work at this time. The all_on_start does run all
# # the tests but I can't figure out a return value that actually makes
# # ANY specs run after a single file changes but the puts works before it.
# #
# # Funny, if I return "spec/javascripts" it tries and successfully does
# # run all the tests; however, if I am specific like
# #
# # spec/javascripts/core/api.spec.js
# #
# # Then it doesn't work. Can try some alternatives like without the filename
# # or without just the file extension.
# #
# # Doesn't work when set to spec/javascripts/core either. Weird.
# #
# # TODO:
# # Figured out an idea. Run the web server in a separate console and see
# # what pages are requested. Maybe can figure out what URL is requested
# # when given the return value below.
# # "spec/javascripts/core/api.spec.js"
# }
# watch(%r{^spec/(.+?\.js)$}) { |m|
# path = m[0]
# puts "Jasmine spec should run after this for #{path}"
# path
# }
# end