tech(): made config system check for generated css or javascript files and panic if there are none, also if there is a public_gen directory it will use that, even if static root is set to public

This commit is contained in:
Torkel Ödegaard
2015-09-10 13:34:32 +02:00
parent da832368f0
commit 0b5f40e66c
4 changed files with 25 additions and 8 deletions

View File

@@ -354,6 +354,23 @@ func setHomePath(args *CommandLineArgs) {
}
}
func getStaticRootPath(configValue string) string {
if configValue != "public" {
return configValue
}
if _, err := os.Stat(path.Join(HomePath, configValue, "css")); err == nil {
return configValue
}
if _, err := os.Stat(path.Join(HomePath, "public_gen", "css")); err == nil {
return "public_gen"
}
log.Fatal(3, "Failed to detect generated css or javascript files in static root (%s), have you executed default grunt task?", configValue)
return ""
}
func NewConfigContext(args *CommandLineArgs) {
setHomePath(args)
loadConfiguration(args)
@@ -373,7 +390,7 @@ func NewConfigContext(args *CommandLineArgs) {
Domain = server.Key("domain").MustString("localhost")
HttpAddr = server.Key("http_addr").MustString("0.0.0.0")
HttpPort = server.Key("http_port").MustString("3000")
StaticRootPath = makeAbsolute(server.Key("static_root_path").String(), HomePath)
StaticRootPath = makeAbsolute(getStaticRootPath(server.Key("static_root_path").String()), HomePath)
RouterLogging = server.Key("router_logging").MustBool(false)
EnableGzip = server.Key("enable_gzip").MustBool(false)
EnforceDomain = server.Key("enforce_domain").MustBool(false)