Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
286ee1d8
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
286ee1d8
编写于
8月 09, 2019
作者:
K
Kevin (Kun) "Kassimo" Qian
提交者:
Ryan Dahl
8月 09, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix dynamic import base path problem for REPL and eval (#2757)
上级
83d5362f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
33 addition
and
3 deletion
+33
-3
cli/worker.rs
cli/worker.rs
+6
-2
core/module_specifier.rs
core/module_specifier.rs
+16
-1
tests/041_dyn_import_eval.out
tests/041_dyn_import_eval.out
+1
-0
tests/041_dyn_import_eval.test
tests/041_dyn_import_eval.test
+2
-0
tests/042_dyn_import_evalcontext.test
tests/042_dyn_import_evalcontext.test
+2
-0
tests/042_dyn_import_evalcontext.ts
tests/042_dyn_import_evalcontext.ts
+4
-0
tests/042_dyn_import_evalcontext.ts.out
tests/042_dyn_import_evalcontext.ts.out
+1
-0
tools/integration_tests.py
tools/integration_tests.py
+1
-0
未找到文件。
cli/worker.rs
浏览文件 @
286ee1d8
...
...
@@ -9,8 +9,10 @@ use deno::RecursiveLoad;
use
deno
::
StartupData
;
use
futures
::
Async
;
use
futures
::
Future
;
use
std
::
env
;
use
std
::
sync
::
Arc
;
use
std
::
sync
::
Mutex
;
use
url
::
Url
;
/// Wraps deno::Isolate to provide source maps, ops for the CLI, and
/// high-level module loading
...
...
@@ -55,9 +57,11 @@ impl Worker {
Self
{
isolate
,
state
}
}
/// Same as execute2() but the filename defaults to "
<anonymous>
".
/// Same as execute2() but the filename defaults to "
$CWD/__anonymous__
".
pub
fn
execute
(
&
mut
self
,
js_source
:
&
str
)
->
Result
<
(),
ErrBox
>
{
self
.execute2
(
"<anonymous>"
,
js_source
)
let
path
=
env
::
current_dir
()
.unwrap
()
.join
(
"__anonymous__"
);
let
url
=
Url
::
from_file_path
(
path
)
.unwrap
();
self
.execute2
(
url
.as_str
(),
js_source
)
}
/// Executes the provided JavaScript source code. The js_filename argument is
...
...
core/module_specifier.rs
浏览文件 @
286ee1d8
...
...
@@ -46,6 +46,10 @@ impl fmt::Display for ModuleResolutionError {
pub
struct
ModuleSpecifier
(
Url
);
impl
ModuleSpecifier
{
fn
is_dummy_specifier
(
specifier
:
&
str
)
->
bool
{
specifier
==
"<unknown>"
}
pub
fn
as_url
(
&
self
)
->
&
Url
{
&
self
.0
}
...
...
@@ -80,7 +84,18 @@ impl ModuleSpecifier {
// 3. Return the result of applying the URL parser to specifier with base
// URL as the base URL.
Err
(
ParseError
::
RelativeUrlWithoutBase
)
=>
{
let
base
=
Url
::
parse
(
base
)
.map_err
(
InvalidBaseUrl
)
?
;
let
base
=
if
ModuleSpecifier
::
is_dummy_specifier
(
base
)
{
// Handle <unknown> case, happening under e.g. repl.
// Use CWD for such case.
// Forcefully join base to current dir.
// Otherwise, later joining in Url would be interpreted in
// the parent directory (appending trailing slash does not work)
let
path
=
current_dir
()
.unwrap
()
.join
(
base
);
Url
::
from_file_path
(
path
)
.unwrap
()
}
else
{
Url
::
parse
(
base
)
.map_err
(
InvalidBaseUrl
)
?
};
base
.join
(
&
specifier
)
.map_err
(
InvalidUrl
)
?
}
...
...
tests/041_dyn_import_eval.out
0 → 100644
浏览文件 @
286ee1d8
{ isMod4: true }
tests/041_dyn_import_eval.test
0 → 100644
浏览文件 @
286ee1d8
args
:
eval
import
(
'./tests/subdir/mod4.js'
)
.
then
(
console
.
log
)
output
:
tests
/
041_
dyn_import_eval
.
out
tests/042_dyn_import_evalcontext.test
0 → 100644
浏览文件 @
286ee1d8
args
:
run
--
reload
tests
/
042_
dyn_import_evalcontext
.
ts
output
:
tests
/
042_
dyn_import_evalcontext
.
ts
.
out
tests/042_dyn_import_evalcontext.ts
0 → 100644
浏览文件 @
286ee1d8
// @ts-ignore
Deno
.
core
.
evalContext
(
"
(async () => console.log(await import('./tests/subdir/mod4.js')))()
"
);
tests/042_dyn_import_evalcontext.ts.out
0 → 100644
浏览文件 @
286ee1d8
{ isMod4: true }
tools/integration_tests.py
浏览文件 @
286ee1d8
...
...
@@ -60,6 +60,7 @@ class TestIntegrations(DenoTestCase):
if
not
args
:
return
# TODO(kevinkassimo): better args parsing with quotation marks.
args
=
args
.
split
(
" "
)
check_stderr
=
str2bool
(
test
.
get
(
"check_stderr"
,
"false"
))
stderr
=
subprocess
.
STDOUT
if
check_stderr
else
open
(
os
.
devnull
,
'w'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录