ui tests: check both locally and globally for node modules

Change-Id: I1378e07c055b85402296ca0bfc5c4ba14ae8c2bf
This commit is contained in:
mpl 2014-06-06 23:29:08 +02:00
parent 678d7cc45a
commit ae4716fcf1
1 changed files with 19 additions and 7 deletions

View File

@ -39,13 +39,25 @@ func checkSystemRequirements() error {
}
}
c := exec.Command("npm", "list", "--depth=0")
b, _ := c.Output()
s := string(b)
modules := []string{"mocha", "assert"}
for _, m := range modules {
if !strings.Contains(s, fmt.Sprintf(" %s@", m)) {
return fmt.Errorf("Required npm module %v not present", m)
checkModules := func(globally bool) error {
args := []string{"list", "--depth=0"}
if globally {
args = append([]string{"-g"}, args...)
}
c := exec.Command("npm", args...)
b, _ := c.Output()
s := string(b)
modules := []string{"mocha", "assert"}
for _, m := range modules {
if !strings.Contains(s, fmt.Sprintf(" %s@", m)) {
return fmt.Errorf("Required npm module %v not present", m)
}
}
return nil
}
if err := checkModules(true); err != nil {
if err := checkModules(false); err != nil {
return err
}
}
return nil