Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xtuc committed Feb 3, 2020
1 parent bf578d8 commit 39eb0b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
4 changes: 4 additions & 0 deletions cmd/checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func lintPackage(name string) {
} else {
warn(ctx, ".autoupdate should not be null. Package will never auto-update")
}

if pckg.Repository.Repotype != "git" {
err(ctx, "Unsupported .repository.type: "+pckg.Repository.Repotype)
}
}

func err(ctx context.Context, s string) {
Expand Down
36 changes: 21 additions & 15 deletions packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,29 @@ func ReadPackageJSON(ctx context.Context, file string) (*Package, error) {
case "autoupdate":
{
if valuemap, ok := value.(map[string]interface{}); ok {
p.Autoupdate = &Autoupdate{
Source: valuemap["source"].(string),
Target: valuemap["target"].(string),
}
if fileMap, ok := valuemap["fileMap"].([]interface{}); ok {
p.Autoupdate.FileMap = new([]FileMap)
for _, rawvalue := range fileMap {
value := rawvalue.(map[string]interface{})
autoupdateFileMap := FileMap{
BasePath: stringInObject("basePath", value),
Files: make([]string, 0),
}
for _, file := range value["files"].([]interface{}) {
autoupdateFileMap.Files = append(autoupdateFileMap.Files, file.(string))
source, sourceok := valuemap["source"].(string)
target, targetok := valuemap["target"].(string)
if sourceok && targetok {
p.Autoupdate = &Autoupdate{
Source: source,
Target: target,
}
if fileMap, ok := valuemap["fileMap"].([]interface{}); ok {
p.Autoupdate.FileMap = new([]FileMap)
for _, rawvalue := range fileMap {
value := rawvalue.(map[string]interface{})
autoupdateFileMap := FileMap{
BasePath: stringInObject("basePath", value),
Files: make([]string, 0),
}
for _, file := range value["files"].([]interface{}) {
autoupdateFileMap.Files = append(autoupdateFileMap.Files, file.(string))
}
*p.Autoupdate.FileMap = append(*p.Autoupdate.FileMap, autoupdateFileMap)
}
*p.Autoupdate.FileMap = append(*p.Autoupdate.FileMap, autoupdateFileMap)
}
} else {
return nil, errors.New(fmt.Sprintf("failed to parse %s: unsupported Autoupdate map", file))
}
} else {
return nil, errors.New(fmt.Sprintf("failed to parse %s: unsupported Autoupdate", file))
Expand Down

0 comments on commit 39eb0b6

Please sign in to comment.