-
Notifications
You must be signed in to change notification settings - Fork 16
/
native.go
39 lines (32 loc) · 1.07 KB
/
native.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
package v1alpha
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"github.com/saucelabs/saucectl/internal/msg"
)
// Config represents the cypress.json native configuration file.
type Config struct {
// Path is the location of the config file itself.
Path string `yaml:"-" json:"-"`
FixturesFolder interface{} `json:"fixturesFolder,omitempty"`
IntegrationFolder string `json:"integrationFolder,omitempty"`
PluginsFile string `json:"pluginsFile,omitempty"`
SupportFile string `json:"supportFile,omitempty"`
}
// AbsIntegrationFolder returns the absolute path to Config.IntegrationFolder.
func (c Config) AbsIntegrationFolder() string {
return filepath.Join(filepath.Join(filepath.Dir(c.Path), c.IntegrationFolder))
}
// configFromFile loads cypress configuration into Config structure.
func configFromFile(fileName string) (Config, error) {
var c Config
fd, err := os.Open(fileName)
if err != nil {
return c, fmt.Errorf(msg.UnableToLocateCypressCfg, fileName)
}
err = json.NewDecoder(fd).Decode(&c)
c.Path = fileName
return c, err
}