Skip to content

Commit

Permalink
chore: 检查不包含通配符
Browse files Browse the repository at this point in the history
  • Loading branch information
Cnotech committed Nov 11, 2023
1 parent e22e0e7 commit 4bfbbdb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/nep/definition/4-steps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Tag } from "../../components/tag.tsx"
* 示例:`to = "./config"`
* 校验规则:
* 是合法路径
* 不包含通配符
#### overwrite
<Tag>可选</Tag> 是否覆盖,缺省为 `false`
* 类型:`bool`
Expand Down Expand Up @@ -167,6 +168,7 @@ import { Tag } from "../../components/tag.tsx"
* 示例:`to = "./bin"`
* 校验规则:
* 是合法路径
* 不包含通配符
#### overwrite
<Tag>可选</Tag> 是否覆盖,缺省为 `false`
* 类型:`bool`
Expand All @@ -187,6 +189,7 @@ import { Tag } from "../../components/tag.tsx"
```
* 校验规则:
* 是合法路径
* 不包含通配符
#### overwrite
<Tag>可选</Tag> 是否覆盖,缺省为 false。
* 类型:`bool`
Expand Down
12 changes: 11 additions & 1 deletion src/types/steps/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct StepCopy {
/// 目标路径,支持相对路径和绝对路径。
//# `to = "./config"`
//@ 是合法路径
//@ 不包含通配符
pub to: String,
/// 是否覆盖,缺省为 `false`。
//# `overwrite = true`
Expand Down Expand Up @@ -198,7 +199,16 @@ impl Verifiable for StepCopy {
fn verify_self(&self, located: &String) -> Result<()> {
values_validator_path(&self.from)?;
values_validator_path(&self.to)?;
common_wild_match_verify(&self.from, &self.to, located)
common_wild_match_verify(&self.from, &self.to, located)?;
// 检查 to 是否包含通配符
if contains_wild_match(&self.to) {
return Err(anyhow!(
"Error(Copy):Field 'to' shouldn't contain wild match : '{to}'",
to = &self.to
));
}

Ok(())
}
}

Expand Down
1 change: 1 addition & 0 deletions src/types/steps/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct StepMove {
/// 目标路径,支持相对路径和绝对路径。
//# `to = "./bin"`
//@ 是合法路径
//@ 不包含通配符
pub to: String,
/// 是否覆盖,缺省为 `false`。
//# `overwrite = "true"`
Expand Down
1 change: 1 addition & 0 deletions src/types/steps/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct StepNew {
//# at = "${Desktop}/Microsoft/"
//# ```
//@ 是合法路径
//@ 不包含通配符
pub at: String,
/// 是否覆盖,缺省为 false。
//# `overwrite = "true"`
Expand Down

0 comments on commit 4bfbbdb

Please sign in to comment.