Skip to content

Commit

Permalink
Merge pull request #448 from moonbitlang/allow_alias_not_set
Browse files Browse the repository at this point in the history
allow alias not set when path provided
  • Loading branch information
Young-Flash authored Nov 5, 2024
2 parents f3e703d + 65f6e0d commit 3e1c6b7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"alias": "lib3"
},
{
"path": "moonbitlang/import004/lib4",
"alias": ""
"path": "moonbitlang/import004/lib4"
}
]
}
6 changes: 4 additions & 2 deletions crates/moonbuild/template/pkg.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,14 @@
{
"type": "object",
"required": [
"alias",
"path"
],
"properties": {
"alias": {
"type": "string"
"type": [
"string",
"null"
]
},
"path": {
"type": "string"
Expand Down
14 changes: 7 additions & 7 deletions crates/moonutil/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub enum PkgJSONImportItem {
String(String),
Object {
path: String,
alias: String,
alias: Option<String>,
value: Option<Vec<String>>,
},
}
Expand Down Expand Up @@ -503,13 +503,13 @@ pub fn convert_pkg_json_to_package(j: MoonPkgJSON) -> anyhow::Result<MoonPkg> {
path,
alias,
value: _,
} => {
if alias.is_empty() {
imports.push(Import::Simple(path));
} else {
imports.push(Import::Alias { path, alias })
} => match alias {
None => imports.push(Import::Simple(path)),
Some(alias) if alias.is_empty() => {
imports.push(Import::Simple(path))
}
}
Some(alias) => imports.push(Import::Alias { path, alias }),
},
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions docs/manual-zh/src/source/pkg_json_schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,14 @@
{
"type": "object",
"required": [
"alias",
"path"
],
"properties": {
"alias": {
"type": "string"
"type": [
"string",
"null"
]
},
"path": {
"type": "string"
Expand Down
6 changes: 4 additions & 2 deletions docs/manual/src/source/pkg_json_schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,14 @@
{
"type": "object",
"required": [
"alias",
"path"
],
"properties": {
"alias": {
"type": "string"
"type": [
"string",
"null"
]
},
"path": {
"type": "string"
Expand Down

0 comments on commit 3e1c6b7

Please sign in to comment.