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

vrepl: fix $tmpl('hello.txt') (fix #16789) (#16793)

This commit is contained in:
yuyi 2022-12-29 17:30:25 +08:00 committed by GitHub
parent ed06618498
commit f4b110b1a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 0 deletions

View File

@ -811,6 +811,7 @@ fn (mut p Parser) other_stmts(cur_stmt ast.Stmt) ast.Stmt {
}
p.open_scope()
p.cur_fn_name = 'main.main'
mut stmts := []ast.Stmt{}
if cur_stmt != ast.empty_stmt {
stmts << cur_stmt

View File

@ -0,0 +1,3 @@
$tmpl('./tmpl/hello.txt')
===output===
hello

View File

@ -49,6 +49,9 @@ pub fn run_repl_file(wd string, vexec string, file string) !string {
input_temporary_filename := os.real_path(os.join_path(wd, 'input_temporary_filename.txt'))
os.write_file(input_temporary_filename, input) or { panic(err) }
os.write_file(os.real_path(os.join_path(wd, 'original.txt')), fcontent) or { panic(err) }
os.cp_all('vlib/v/tests/repl/tmpl', os.real_path(os.join_path(wd, 'tmpl')), true) or {
panic(err)
}
rcmd := '${os.quoted_path(vexec)} repl -replfolder ${os.quoted_path(wd)} -replprefix "${fname}." < ${os.quoted_path(input_temporary_filename)}'
r := os.execute(rcmd)
if r.exit_code != 0 {

View File

@ -0,0 +1 @@
hello