Skip to content

Commit

Permalink
feat(license) read content from custom license file
Browse files Browse the repository at this point in the history
  • Loading branch information
anhgelus committed Mar 29, 2023
1 parent 8fcbe97 commit d909359
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ func main() {
utils.HandleError(err)
contextPath, err := os.Getwd()
utils.HandleError(err)
println(contextPath)
for _, license := range licenses {
println("Path in main.go:", license.Path)
}
contextPath += "/" + arg.ConfigPath
config.AddLicensesToMap(licenses, contextPath)
println("")
}
arg.HandleArgs()

Expand All @@ -46,7 +44,9 @@ func findLicense(license args.License) string {
utils.HandleError(err)
return string(content)
}
return ""
b, err := os.ReadFile(license.File)
utils.HandleError(err)
return string(b)
}

func parseLicense(arg *args.Arguments, license string) string {
Expand Down
3 changes: 0 additions & 3 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@ func GetLicenseConfigs(path string) ([]LicenseConfig, error) {
}

func (license *LicenseConfig) AddToMap(contextPath string) {
println("Path:", license.Path)
args.AddLicense(license.ToLicense(contextPath), license.Identifier)
}

func AddLicensesToMap(licenses []LicenseConfig, contextPath string) {
println("F:", licenses[0].Path)
for _, license := range licenses {
println("P:", license.Path)
license.AddToMap(contextPath)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func DecodeToml(content []byte, t any) {
//
// contextPath: the contextual path, with a slash (/) at the end
func RelativeToAbsolute(path string, contextPath string) string {
println(path, contextPath)
switch string(path[0]) {
case "/":
return path
Expand Down

0 comments on commit d909359

Please sign in to comment.