diff --git a/cmd/tools/vcreate/project_model_bin.v b/cmd/tools/vcreate/project_model_bin.v index 33c9d50430..865fec3312 100644 --- a/cmd/tools/vcreate/project_model_bin.v +++ b/cmd/tools/vcreate/project_model_bin.v @@ -3,9 +3,9 @@ module main import os fn (mut c Create) set_bin_project_files() { - main_path := os.join_path('src', 'main.v') + base := if c.new_dir { c.name } else { '' } c.files << ProjectFiles{ - path: if c.new_dir { os.join_path(c.name, main_path) } else { main_path } + path: os.join_path(base, 'src', 'main.v') content: "module main fn main() { diff --git a/cmd/tools/vcreate/project_model_lib.v b/cmd/tools/vcreate/project_model_lib.v index d2069e51d1..32dc101a02 100644 --- a/cmd/tools/vcreate/project_model_lib.v +++ b/cmd/tools/vcreate/project_model_lib.v @@ -3,8 +3,9 @@ module main import os fn (mut c Create) set_lib_project_files() { + base := if c.new_dir { c.name } else { '' } c.files << ProjectFiles{ - path: os.join_path(c.name, 'src', c.name + '.v') + path: os.join_path(base, 'src', c.name + '.v') content: 'module ${c.name} // square calculates the second power of `x` @@ -14,7 +15,7 @@ pub fn square(x int) int { ' } c.files << ProjectFiles{ - path: os.join_path(c.name, 'tests', 'square_test.v') + path: os.join_path(base, 'tests', 'square_test.v') content: 'import ${c.name} fn test_square() { diff --git a/cmd/tools/vcreate/project_model_web.v b/cmd/tools/vcreate/project_model_web.v index 2500311370..0c07c86444 100644 --- a/cmd/tools/vcreate/project_model_web.v +++ b/cmd/tools/vcreate/project_model_web.v @@ -3,8 +3,9 @@ module main import os { join_path } fn (mut c Create) set_web_project_files() { + base := if c.new_dir { c.name } else { '' } c.files << ProjectFiles{ - path: join_path(c.name, 'src', 'databases', 'config_databases_sqlite.v') + path: join_path(base, 'src', 'databases', 'config_databases_sqlite.v') content: "module databases import db.sqlite // can change to 'db.mysql', 'db.pg' @@ -16,7 +17,7 @@ pub fn create_db_connection() !sqlite.DB { " } c.files << ProjectFiles{ - path: join_path(c.name, 'src', 'templates', 'header_component.html') + path: join_path(base, 'src', 'templates', 'header_component.html') content: "