-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwarn.go
67 lines (63 loc) · 1002 Bytes
/
warn.go
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
package main
import (
"fmt"
"os"
"os/exec"
)
func warn(directory string) error {
if directory == "" {
return fmt.Errorf("warn directory should not be nil")
}
find := exec.Command(
"/usr/bin/find",
directory,
"-name",
"*.swift",
"-print0",
)
match := exec.Command(
"xargs",
"-0",
"egrep",
"--with-filename",
"--line-number",
"--only-matching",
"(UIImage|NSImage)\\(named",
)
sed := exec.Command(
"sed",
"-E",
"s/(UIImage|NSImage).*/ warning: legacy use of imageNamed; consider using Resourceful/",
)
stdin, err := find.StdoutPipe()
match.Stdin = stdin
if err != nil {
return err
}
sed.Stdin, err = match.StdoutPipe()
if err != nil {
return err
}
sed.Stdout = os.Stderr
err = match.Start()
if err != nil {
return err
}
err = sed.Start()
if err != nil {
return err
}
err = find.Run()
if err != nil {
return err
}
err = match.Wait()
if err != nil {
return err
}
err = sed.Wait()
if err != nil {
return err
}
return nil
}