diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs index ba61d352d3..a866660f36 100644 --- a/cli/tools/registry/mod.rs +++ b/cli/tools/registry/mod.rs @@ -97,11 +97,10 @@ pub async fn publish( match cli_options.start_dir.maybe_deno_json() { Some(deno_json) => { debug_assert!(!deno_json.is_package()); + if deno_json.json.name.is_none() { + bail!("Missing 'name' field in '{}'.", deno_json.specifier); + } error_missing_exports_field(deno_json)?; - bail!( - "Missing 'name' or 'exports' field in '{}'.", - deno_json.specifier - ); } None => { bail!( diff --git a/tests/specs/publish/missing_name/__test__.jsonc b/tests/specs/publish/missing_name/__test__.jsonc new file mode 100644 index 0000000000..241bb87e04 --- /dev/null +++ b/tests/specs/publish/missing_name/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "publish.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/missing_name/deno.json b/tests/specs/publish/missing_name/deno.json new file mode 100644 index 0000000000..4b0018cf62 --- /dev/null +++ b/tests/specs/publish/missing_name/deno.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/publish/missing_name/mod.ts b/tests/specs/publish/missing_name/mod.ts new file mode 100644 index 0000000000..8d9b8a22a1 --- /dev/null +++ b/tests/specs/publish/missing_name/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/publish/missing_name/publish.out b/tests/specs/publish/missing_name/publish.out new file mode 100644 index 0000000000..10e0688ef2 --- /dev/null +++ b/tests/specs/publish/missing_name/publish.out @@ -0,0 +1 @@ +error: Missing 'name' field in 'file:///[WILDCARD]deno.json'.