module Utils class InreplaceError < RuntimeError def initialize(errors) formatted_errors = errors.inject("inreplace failed\n") do |s, (path, errs)| s << "#{path}:\n" << errs.map { |e| " #{e}\n" }.join end super formatted_errors end end module Inreplace # Sometimes we have to change a bit before we install. Mostly we # prefer a patch but if you need the `prefix` of this formula in the # patch you have to resort to `inreplace`, because in the patch # you don't have access to any var defined by the formula. Only # HOMEBREW_PREFIX is available in the embedded patch. # inreplace supports regular expressions. #
inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"
def inreplace(paths, before = nil, after = nil, audit_result = true) errors = {} Array(paths).each do |path| s = File.open(path, "rb", &:read).extend(StringInreplaceExtension) if before.nil? && after.nil? yield s else after = after.to_s if after.is_a? Symbol s.gsub!(before, after, audit_result) end errors[path] = s.errors unless s.errors.empty? Pathname(path).atomic_write(s) end raise InreplaceError, errors unless errors.empty? end module_function :inreplace end end le class='tabs'> aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/ngInclude.js
blob: d4eacbe3e0affa93e5de99825dccd64c744e30b0 (plain)
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