js: fix wrong filename and invalid backend selected when using -o .js (#6777)

pull/6785/head
pancake 2020-11-08 17:45:32 +01:00 committed by GitHub
parent 2994e7150f
commit af5836202c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -45,7 +45,11 @@ pub fn (mut b Builder) compile_js() {
println('all .v files:')
println(files)
}
b.build_js(files, b.pref.out_name + '.js')
mut name := b.pref.out_name
if !name.ends_with('.js') {
name += '.js'
}
b.build_js(files, name)
}
fn (mut b Builder) run_js() {

View File

@ -316,6 +316,9 @@ pub fn parse_args(args []string) (&Preferences, string) {
}
'-o' {
res.out_name = cmdline.option(current_args, '-o', '')
if res.out_name.ends_with('.js') {
res.backend = .js
}
i++
}
'-b' {