1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

bring back local modules

This commit is contained in:
Alexander Medvednikov
2019-08-04 00:03:52 +02:00
parent 9eb385d9ee
commit 01531369f7
2 changed files with 29 additions and 15 deletions

View File

@ -4,6 +4,8 @@
module main
import os
struct ModDepGraphNode {
mut:
name string
@ -145,3 +147,25 @@ pub fn(graph &ModDepGraph) display() {
}
}
}
// 'strings' => 'VROOT/vlib/strings'
// 'installed_mod' => '~/.vmodules/installed_mod'
// 'local_mod' => '/path/to/current/dir/local_mod'
fn (v &V) find_module_path(mod string) string {
mod_path := v.module_path(mod)
// First check for local modules in the same directory
mut import_path := os.getwd() + '/$mod_path'
// Now search in vlib/
if !os.dir_exists(import_path) {
import_path = '$v.lang_dir/vlib/$mod_path'
}
//println('ip=$import_path')
// Finally try modules installed with vpm (~/.vmodules)
if !os.dir_exists(import_path) {
import_path = '$ModPath/$mod_path'
if !os.dir_exists(import_path){
panic('module "$mod" not found')
}
}
return import_path
}