1
0
Fork 0
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:
Marvin Hagemeister 2024-11-28 18:11:36 +01:00 committed by GitHub
parent 12aea2014a
commit 3553aa9132
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 4 deletions

View file

@ -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!(

View file

@ -0,0 +1,5 @@
{
"args": "publish --token 'sadfasdf'",
"output": "publish.out",
"exitCode": 1
}

View file

@ -0,0 +1,4 @@
{
"version": "1.0.0",
"exports": "./mod.ts"
}

View file

@ -0,0 +1,3 @@
export function add(a: number, b: number): number {
return a + b;
}

View file

@ -0,0 +1 @@
error: Missing 'name' field in 'file:///[WILDCARD]deno.json'.