mirror of
https://github.com/denoland/deno.git
synced 2025-01-02 20:38:47 -05:00
fix(publish): error on missing name field (#27131)
This PR improves the error output on publish when the `name` filed is missing: ```json { "exports": "./mod.ts", "version": "0.0.1" } ``` Before: ```sh deno publish --dry-run error: You did not specify an entrypoint in file:///Users/marvinh/dev/test/deno-pkg-timers/deno.json. Add `exports` mapping in the configuration file, eg: { "name": "@scope/name", "version": "0.0.0", "exports": "<path_to_entrypoint>" } ``` After: ```sh deno publish --dry-run error: Missing 'name' field in 'file:///Users/marvinh/dev/test/deno-pkg-timers/deno.json'. ``` Fixes https://github.com/denoland/deno/issues/27116
This commit is contained in:
parent
12aea2014a
commit
3553aa9132
5 changed files with 16 additions and 4 deletions
|
@ -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!(
|
||||
|
|
5
tests/specs/publish/missing_name/__test__.jsonc
Normal file
5
tests/specs/publish/missing_name/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "publish --token 'sadfasdf'",
|
||||
"output": "publish.out",
|
||||
"exitCode": 1
|
||||
}
|
4
tests/specs/publish/missing_name/deno.json
Normal file
4
tests/specs/publish/missing_name/deno.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"exports": "./mod.ts"
|
||||
}
|
3
tests/specs/publish/missing_name/mod.ts
Normal file
3
tests/specs/publish/missing_name/mod.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
1
tests/specs/publish/missing_name/publish.out
Normal file
1
tests/specs/publish/missing_name/publish.out
Normal file
|
@ -0,0 +1 @@
|
|||
error: Missing 'name' field in 'file:///[WILDCARD]deno.json'.
|
Loading…
Reference in a new issue