From d5cf4d6fd5c3ebcabe97ec7bf2eb79204421fee9 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 30 Oct 2019 20:53:30 +0300 Subject: [PATCH] compiler: -o dir/file: create a new directory if it doesn't exist --- vlib/compiler/main.v | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index bea52eacfc..00f6ad5da5 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -840,6 +840,15 @@ pub fn new_v(args[]string) &V { base := os.getwd().all_after(os.path_separator) 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 // No OS specifed? Use current system if target_os == '' {