mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
Merge branch 'main' into hickory_update
This commit is contained in:
commit
58f0b66806
7 changed files with 28 additions and 12 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!(
|
||||
|
|
|
@ -578,7 +578,7 @@ class FsFile {
|
|||
this.#rid = rid;
|
||||
if (!symbol || symbol !== SymbolFor("Deno.internal.FsFile")) {
|
||||
throw new TypeError(
|
||||
"`Deno.FsFile` cannot be constructed, use `Deno.open()` or `Deno.openSync()` instead.",
|
||||
"'Deno.FsFile' cannot be constructed, use 'Deno.open()' or 'Deno.openSync()' instead",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -713,11 +713,15 @@ function checkOpenOptions(options) {
|
|||
(val) => val === true,
|
||||
).length === 0
|
||||
) {
|
||||
throw new Error("OpenOptions requires at least one option to be true");
|
||||
throw new Error(
|
||||
"'options' requires at least one option to be true",
|
||||
);
|
||||
}
|
||||
|
||||
if (options.truncate && !options.write) {
|
||||
throw new Error("'truncate' option requires 'write' option");
|
||||
throw new Error(
|
||||
"'truncate' option requires 'write' to be true",
|
||||
);
|
||||
}
|
||||
|
||||
const createOrCreateNewWithoutWriteOrAppend =
|
||||
|
@ -726,7 +730,7 @@ function checkOpenOptions(options) {
|
|||
|
||||
if (createOrCreateNewWithoutWriteOrAppend) {
|
||||
throw new Error(
|
||||
"'create' or 'createNew' options require 'write' or 'append' option",
|
||||
"'create' or 'createNew' options require 'write' or 'append' to be true",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
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'.
|
|
@ -137,7 +137,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { write: false });
|
||||
},
|
||||
Error,
|
||||
"OpenOptions requires at least one option to be true",
|
||||
"'options' requires at least one option to be true",
|
||||
);
|
||||
|
||||
await assertRejects(
|
||||
|
@ -145,7 +145,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { truncate: true, write: false });
|
||||
},
|
||||
Error,
|
||||
"'truncate' option requires 'write' option",
|
||||
"'truncate' option requires 'write' to be true",
|
||||
);
|
||||
|
||||
await assertRejects(
|
||||
|
@ -153,7 +153,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { create: true, write: false });
|
||||
},
|
||||
Error,
|
||||
"'create' or 'createNew' options require 'write' or 'append' option",
|
||||
"'create' or 'createNew' options require 'write' or 'append' to be true",
|
||||
);
|
||||
|
||||
await assertRejects(
|
||||
|
@ -161,7 +161,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { createNew: true, append: false });
|
||||
},
|
||||
Error,
|
||||
"'create' or 'createNew' options require 'write' or 'append' option",
|
||||
"'create' or 'createNew' options require 'write' or 'append' to be true",
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue