Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
fd432e23
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,发现更多精彩内容 >>
未验证
提交
fd432e23
编写于
3月 25, 2020
作者:
R
Ryan Dahl
提交者:
GitHub
3月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade: dprint 0.9.5 (#4491)
上级
5d7bcf86
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
39 deletion
+41
-39
Cargo.lock
Cargo.lock
+7
-6
cli/Cargo.toml
cli/Cargo.toml
+1
-1
cli/fmt.rs
cli/fmt.rs
+33
-32
未找到文件。
Cargo.lock
浏览文件 @
fd432e23
...
...
@@ -552,24 +552,25 @@ checksum = "52ba6eb47c2131e784a38b726eb54c1e1484904f013e576a25354d0124161af6"
[[package]]
name = "dprint-core"
version = "0.1
1
.0"
version = "0.1
2
.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
37d1aa8ea00ca5fb5a92278a6596b14b0f8336c3d0b6c6cbde4b46817dcd2ed0
"
checksum = "
8fb2332f10c6acf94b5d469ed993cf52ed7a1369b80523fb9cb21fa10c6b6887
"
dependencies = [
"serde",
]
[[package]]
name = "dprint-plugin-typescript"
version = "0.
8.1
"
version = "0.
9.5
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
6dcf2ac362cb71dac70767cd23fba63063fb47bdb84ccef8b42ba03e17c0451d
"
checksum = "
b40a2ed665c9cb3192b689bcfc6934a1dbe16009e363c84b6db19ce1c36ef274
"
dependencies = [
"dprint-core",
"serde",
"swc_common",
"swc_ecma_ast",
"swc_ecma_parser",
"swc_ecma_parser_macros",
]
[[package]]
...
...
@@ -2207,9 +2208,9 @@ dependencies = [
[[package]]
name = "swc_ecma_parser"
version = "0.21.
5
"
version = "0.21.
6
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
9519ab89ac37f65eb7d58f892f89aaa4dc64979b660a029025dbb9ee2a2b2903
"
checksum = "
701e681b7783c5b9d3df9e18592494ca3cba7a2fa8fc98d4d4f423ae993df155
"
dependencies = [
"either",
"enum_kind",
...
...
cli/Cargo.toml
浏览文件 @
fd432e23
...
...
@@ -33,7 +33,7 @@ byteorder = "1.3.4"
clap
=
"2.33.0"
dirs
=
"2.0.2"
dlopen
=
"0.1.8"
dprint-plugin-typescript
=
"0.
8.1
"
dprint-plugin-typescript
=
"0.
9.5
"
futures
=
{
version
=
"0.3.4"
,
features
=
[
"compat"
,
"io-compat"
]
}
glob
=
"0.3.0"
http
=
"0.2.0"
...
...
cli/fmt.rs
浏览文件 @
fd432e23
...
...
@@ -37,15 +37,23 @@ fn is_supported(path: &Path) -> bool {
fn
get_config
()
->
dprint
::
configuration
::
Configuration
{
use
dprint
::
configuration
::
*
;
ConfigurationBuilder
::
new
()
.line_width
(
80
)
.indent_width
(
2
)
.next_control_flow_position
(
NextControlFlowPosition
::
SameLine
)
.binary_expression_operator_position
(
OperatorPosition
::
SameLine
)
.brace_position
(
BracePosition
::
SameLine
)
// default is NextLineIfHanging
.comment_line_force_space_after_slashes
(
false
)
.construct_signature_space_after_new_keyword
(
true
)
.build
()
ConfigurationBuilder
::
new
()
.prettier
()
.build
()
}
// TODO(ry) dprint seems to panic unnecessarally sometimes. Until it matures
// we'll use a catch_unwind to avoid passing it on to our users.
fn
format_text_ignore_panic
(
file_path_str
:
&
str
,
file_contents
:
&
str
,
config
:
&
dprint
::
configuration
::
Configuration
,
)
->
Result
<
Option
<
String
>
,
String
>
{
let
catch_result
=
std
::
panic
::
catch_unwind
(||
{
dprint
::
format_text
(
file_path_str
,
file_contents
,
config
)
});
match
catch_result
{
Ok
(
dprint_result
)
=>
dprint_result
,
Err
(
e
)
=>
Err
(
format!
(
"dprint panic '{}' {:?}"
,
file_path_str
,
e
)),
}
}
fn
check_source_files
(
...
...
@@ -57,7 +65,7 @@ fn check_source_files(
for
file_path
in
paths
{
let
file_path_str
=
file_path
.to_string_lossy
();
let
file_contents
=
fs
::
read_to_string
(
&
file_path
)
.unwrap
();
match
dprint
::
format_text
(
&
file_path_str
,
&
file_contents
,
&
config
)
{
match
format_text_ignore_panic
(
&
file_path_str
,
&
file_contents
,
&
config
)
{
Ok
(
None
)
=>
{
// nothing to format, pass
}
...
...
@@ -101,30 +109,23 @@ fn format_source_files(
for
file_path
in
paths
{
let
file_path_str
=
file_path
.to_string_lossy
();
let
file_contents
=
fs
::
read_to_string
(
&
file_path
)
?
;
// TODO(ry) dprint seems to panic unnecessarally sometimes. Until it matures
// we'll use a catch_unwind to avoid passing it on to our users.
let
catch_unwind_result
=
std
::
panic
::
catch_unwind
(||
{
dprint
::
format_text
(
&
file_path_str
,
&
file_contents
,
&
config
)
});
if
let
Ok
(
dprint_result
)
=
catch_unwind_result
{
match
dprint_result
{
Ok
(
None
)
=>
{
// nothing to format, pass
}
Ok
(
Some
(
formatted_text
))
=>
{
if
formatted_text
!=
file_contents
{
println!
(
"{}"
,
file_path_str
);
fs
::
write
(
&
file_path
,
formatted_text
)
?
;
not_formatted_files
.push
(
file_path
);
}
}
Err
(
e
)
=>
{
eprintln!
(
"Error formatting: {}"
,
&
file_path_str
);
eprintln!
(
" {}"
,
e
);
let
dprint_result
=
format_text_ignore_panic
(
&
file_path_str
,
&
file_contents
,
&
config
);
match
dprint_result
{
Ok
(
None
)
=>
{
// nothing to format, pass
}
Ok
(
Some
(
formatted_text
))
=>
{
if
formatted_text
!=
file_contents
{
println!
(
"{}"
,
file_path_str
);
fs
::
write
(
&
file_path
,
formatted_text
)
?
;
not_formatted_files
.push
(
file_path
);
}
}
}
else
{
eprintln!
(
"dprint panic {}"
,
file_path_str
);
Err
(
e
)
=>
{
eprintln!
(
"Error formatting: {}"
,
&
file_path_str
);
eprintln!
(
" {}"
,
e
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录