compiler: -o dir/file: create a new directory if it doesn't exist

pull/2593/head
Alexander Medvednikov 2019-10-30 20:53:30 +03:00
parent e8d34002e1
commit d5cf4d6fd5
1 changed files with 9 additions and 0 deletions

View File

@ -840,6 +840,15 @@ pub fn new_v(args[]string) &V {
base := os.getwd().all_after(os.path_separator) base := os.getwd().all_after(os.path_separator)
out_name = base.trim_space() out_name = base.trim_space()
} }
// `v -o dir/exec`, create "dir/" if it doesn't exist
if out_name.contains(os.path_separator) {
d := out_name.all_before_last(os.path_separator)
println('DIRRR ' + d)
if !os.dir_exists(d) {
println('creating a new directory "$d"')
os.mkdir(d)
}
}
mut _os := OS.mac mut _os := OS.mac
// No OS specifed? Use current system // No OS specifed? Use current system
if target_os == '' { if target_os == '' {