Skip to content

Commit 0b5f40e

Browse files
committed
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
1 parent da83236 commit 0b5f40e

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

pkg/setting/setting.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,23 @@ func setHomePath(args *CommandLineArgs) {
354354
}
355355
}
356356

357+
func getStaticRootPath(configValue string) string {
358+
if configValue != "public" {
359+
return configValue
360+
}
361+
362+
if _, err := os.Stat(path.Join(HomePath, configValue, "css")); err == nil {
363+
return configValue
364+
}
365+
366+
if _, err := os.Stat(path.Join(HomePath, "public_gen", "css")); err == nil {
367+
return "public_gen"
368+
}
369+
370+
log.Fatal(3, "Failed to detect generated css or javascript files in static root (%s), have you executed default grunt task?", configValue)
371+
return ""
372+
}
373+
357374
func NewConfigContext(args *CommandLineArgs) {
358375
setHomePath(args)
359376
loadConfiguration(args)
@@ -373,7 +390,7 @@ func NewConfigContext(args *CommandLineArgs) {
373390
Domain = server.Key("domain").MustString("localhost")
374391
HttpAddr = server.Key("http_addr").MustString("0.0.0.0")
375392
HttpPort = server.Key("http_port").MustString("3000")
376-
StaticRootPath = makeAbsolute(server.Key("static_root_path").String(), HomePath)
393+
StaticRootPath = makeAbsolute(getStaticRootPath(server.Key("static_root_path").String()), HomePath)
377394
RouterLogging = server.Key("router_logging").MustBool(false)
378395
EnableGzip = server.Key("enable_gzip").MustBool(false)
379396
EnforceDomain = server.Key("enforce_domain").MustBool(false)

tasks/build_task.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,27 @@ module.exports = function(grunt) {
4343
});
4444

4545
grunt.registerTask('build-post-process', function() {
46-
grunt.config('copy.public_gen_to_dest', {
46+
grunt.config('copy.public_gen_to_temp', {
4747
expand: true,
4848
cwd: '<%= genDir %>',
4949
src: '**/*',
50-
dest: '<%= destDir %>/public/',
50+
dest: '<%= tempDir %>/public/',
5151
});
5252
grunt.config('copy.backend_bin', {
5353
cwd: 'bin',
5454
expand: true,
5555
src: ['*'],
5656
options: { mode: true},
57-
dest: '<%= destDir %>/bin/'
57+
dest: '<%= tempDir %>/bin/'
5858
});
5959
grunt.config('copy.backend_files', {
6060
expand: true,
6161
src: ['conf/defaults.ini', 'conf/sample.ini', 'vendor/**/*', 'scripts/*'],
6262
options: { mode: true},
63-
dest: '<%= destDir %>'
63+
dest: '<%= tempDir %>'
6464
});
6565

66-
grunt.task.run('copy:public_gen_to_dest');
66+
grunt.task.run('copy:public_gen_to_temp');
6767
grunt.task.run('copy:backend_bin');
6868
grunt.task.run('copy:backend_files');
6969
});

tasks/options/compress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function(config) {
99
files : [
1010
{
1111
expand: true,
12-
cwd: '<%= destDir %>',
12+
cwd: '<%= tempDir %>',
1313
src: ['**/*'],
1414
dest: '<%= pkg.name %>-<%= pkg.version %>/',
1515
},

tasks/options/requirejs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = function(config,grunt) {
7474
];
7575

7676
var fs = require('fs');
77-
var panelPath = config.genDir+'/app/panels';
77+
var panelPath = config.srcDir + '/app/panels';
7878

7979
// create a module for each directory in public/app/panels/
8080
fs.readdirSync(panelPath).forEach(function (panelName) {

0 commit comments

Comments
 (0)