0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-11 14:47:26 -04:00

Merge remote-tracking branch 'origin/Fix-UNC-Path-Permissions-Issue-on-Windows' into Fix-UNC-Path-Permissions-Issue-on-Windows

This commit is contained in:
yazan-abdalrahman 2024-08-21 15:14:34 +03:00
commit a725fe25a2
144 changed files with 884 additions and 157 deletions

View file

@ -4,6 +4,7 @@
"include": [ "include": [
"ban-untagged-todo", "ban-untagged-todo",
"camelcase", "camelcase",
"no-console",
"guard-for-in" "guard-for-in"
], ],
"exclude": [ "exclude": [

26
Cargo.lock generated
View file

@ -1144,7 +1144,7 @@ dependencies = [
[[package]] [[package]]
name = "deno" name = "deno"
version = "1.46.0-rc.2" version = "1.46.0-rc.3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"base32", "base32",
@ -1360,9 +1360,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_config" name = "deno_config"
version = "0.29.0" version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bc5aa53d1c3a3d0b9fd218e3f30f1080312f811b60e1866b88ec9f665447c4e" checksum = "9657dbcc5210407fd9a1b1571310f2fe25c6dd6be2195c964d19f43d70045a95"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"deno_package_json", "deno_package_json",
@ -1389,9 +1389,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_core" name = "deno_core"
version = "0.304.0" version = "0.305.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcb02f25a743fe58a117ed5cfd47c4e640761926e294a1f4ba964a0e2c68b4dc" checksum = "e7c823d9ee0cf31b4b8b6be65bc87a9e6ecb3ed5b244a68bbf25b6b8a477da25"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -1721,9 +1721,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_lockfile" name = "deno_lockfile"
version = "0.21.1" version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b01138860cdf20cfca4c9e6bcda2bbe577f0c784f6f6938205d522ee2b6327ed" checksum = "04beb67705d894d688e818870a701829223f6f485ef3ce0b8b2a7adac98d9583"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@ -1869,9 +1869,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_npm" name = "deno_npm"
version = "0.23.0" version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceef28152643a021fc3487a3ec93ae83996972c087547d97f425c83e15dca932" checksum = "96d72068f4292455d48ac3b90c644ebf3150fb78c26a480cfb235a9642afe95c"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1888,9 +1888,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_ops" name = "deno_ops"
version = "0.180.0" version = "0.181.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bbba184551dfe009836a42c0268fea6b4ad036b5154aec5a7625e7a7ce4e315" checksum = "6c06bd7a0fa5a7bc531a544a889eaf8f3594c22aba147e2efb820c4d8c547a91"
dependencies = [ dependencies = [
"proc-macro-rules", "proc-macro-rules",
"proc-macro2", "proc-macro2",
@ -6252,9 +6252,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_v8" name = "serde_v8"
version = "0.213.0" version = "0.214.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1831a65bad8086cfc993eaead4cbcb00579c085e43b4952a90024e1243f23b4e" checksum = "77304686fddb9b8c915396512a2e7bca70b0b2d07edd1898eeefa22918ef45fb"
dependencies = [ dependencies = [
"num-bigint", "num-bigint",
"serde", "serde",

View file

@ -45,10 +45,10 @@ repository = "https://github.com/denoland/deno"
[workspace.dependencies] [workspace.dependencies]
deno_ast = { version = "=0.41.2", features = ["transpiling"] } deno_ast = { version = "=0.41.2", features = ["transpiling"] }
deno_core = { version = "0.304.0" } deno_core = { version = "0.305.0" }
deno_bench_util = { version = "0.158.0", path = "./bench_util" } deno_bench_util = { version = "0.158.0", path = "./bench_util" }
deno_lockfile = "0.21.1" deno_lockfile = "0.21.2"
deno_media_type = { version = "0.1.4", features = ["module_specifier"] } deno_media_type = { version = "0.1.4", features = ["module_specifier"] }
deno_permissions = { version = "0.24.0", path = "./runtime/permissions" } deno_permissions = { version = "0.24.0", path = "./runtime/permissions" }
deno_runtime = { version = "0.173.0", path = "./runtime" } deno_runtime = { version = "0.173.0", path = "./runtime" }

View file

@ -2,7 +2,7 @@
[package] [package]
name = "deno" name = "deno"
version = "1.46.0-rc.2" version = "1.46.0-rc.3"
authors.workspace = true authors.workspace = true
default-run = "deno" default-run = "deno"
edition.workspace = true edition.workspace = true
@ -65,14 +65,14 @@ winres.workspace = true
[dependencies] [dependencies]
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] } deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
deno_cache_dir = { workspace = true } deno_cache_dir = { workspace = true }
deno_config = { version = "=0.29.0", features = ["workspace", "sync"] } deno_config = { version = "=0.30.1", features = ["workspace", "sync"] }
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "0.146.0", features = ["html", "syntect"] } deno_doc = { version = "0.146.0", features = ["html", "syntect"] }
deno_emit = "=0.44.0" deno_emit = "=0.44.0"
deno_graph = { version = "=0.81.2" } deno_graph = { version = "=0.81.2" }
deno_lint = { version = "=0.63.1", features = ["docs"] } deno_lint = { version = "=0.63.1", features = ["docs"] }
deno_lockfile.workspace = true deno_lockfile.workspace = true
deno_npm = "=0.23.0" deno_npm = "=0.23.1"
deno_package_json.workspace = true deno_package_json.workspace = true
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_semver = "=0.5.10" deno_semver = "=0.5.10"

View file

@ -589,7 +589,7 @@ pub struct Flags {
pub argv: Vec<String>, pub argv: Vec<String>,
pub subcommand: DenoSubcommand, pub subcommand: DenoSubcommand,
pub frozen_lockfile: bool, pub frozen_lockfile: Option<bool>,
pub ca_stores: Option<Vec<String>>, pub ca_stores: Option<Vec<String>>,
pub ca_data: Option<CaData>, pub ca_data: Option<CaData>,
pub cache_blocklist: Vec<String>, pub cache_blocklist: Vec<String>,
@ -5231,7 +5231,7 @@ fn cached_only_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
fn frozen_lockfile_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) { fn frozen_lockfile_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
if let Some(&v) = matches.get_one::<bool>("frozen") { if let Some(&v) = matches.get_one::<bool>("frozen") {
flags.frozen_lockfile = v; flags.frozen_lockfile = Some(v);
} }
} }
@ -10923,10 +10923,10 @@ mod tests {
#[test] #[test]
fn run_with_frozen_lockfile() { fn run_with_frozen_lockfile() {
let cases = [ let cases = [
(Some("--frozen"), true), (Some("--frozen"), Some(true)),
(Some("--frozen=true"), true), (Some("--frozen=true"), Some(true)),
(Some("--frozen=false"), false), (Some("--frozen=false"), Some(false)),
(None, false), (None, None),
]; ];
for (flag, frozen) in cases { for (flag, frozen) in cases {
let mut args = svec!["deno", "run"]; let mut args = svec!["deno", "run"];

View file

@ -147,22 +147,28 @@ impl CliLockfile {
}, },
}; };
let root_folder = workspace.root_folder_configs();
// CLI flag takes precedence over the config
let frozen = flags.frozen_lockfile.unwrap_or_else(|| {
root_folder
.deno_json
.as_ref()
.and_then(|c| c.to_lock_config().ok().flatten().map(|c| c.frozen()))
.unwrap_or(false)
});
let lockfile = if flags.lock_write { let lockfile = if flags.lock_write {
log::warn!( log::warn!(
"{} \"--lock-write\" flag is deprecated and will be removed in Deno 2.", "{} \"--lock-write\" flag is deprecated and will be removed in Deno 2.",
crate::colors::yellow("Warning") crate::colors::yellow("Warning")
); );
CliLockfile::new( CliLockfile::new(Lockfile::new_empty(filename, true), frozen)
Lockfile::new_empty(filename, true),
flags.frozen_lockfile,
)
} else { } else {
Self::read_from_path(filename, flags.frozen_lockfile)? Self::read_from_path(filename, frozen)?
}; };
// initialize the lockfile with the workspace's configuration // initialize the lockfile with the workspace's configuration
let root_url = workspace.root_dir(); let root_url = workspace.root_dir();
let root_folder = workspace.root_folder_configs();
let config = deno_lockfile::WorkspaceConfig { let config = deno_lockfile::WorkspaceConfig {
root: WorkspaceMemberConfig { root: WorkspaceMemberConfig {
package_json_deps: pkg_json_deps(root_folder.pkg_json.as_deref()), package_json_deps: pkg_json_deps(root_folder.pkg_json.as_deref()),

View file

@ -1085,7 +1085,7 @@ impl CliOptions {
}; };
Ok( Ok(
self self
.start_dir .workspace()
.create_resolver( .create_resolver(
CreateResolverOptions { CreateResolverOptions {
pkg_json_dep_resolution, pkg_json_dep_resolution,

View file

@ -1,3 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
const count = 100000; const count = 100000;
for (let i = 0; i < count; i++) console.log("Hello World"); for (let i = 0; i < count; i++) console.log("Hello World");

View file

@ -1,4 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"
? Deno.args ? Deno.args
: [process.argv[2], process.argv[3]]; : [process.argv[2], process.argv[3]];

View file

@ -1,4 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"
? Deno.args ? Deno.args
: [process.argv[2], process.argv[3]]; : [process.argv[2], process.argv[3]];

View file

@ -3,6 +3,7 @@
// TODO(bartlomieju): Replace this with a real HTTP server once // TODO(bartlomieju): Replace this with a real HTTP server once
// https://github.com/denoland/deno/issues/726 is completed. // https://github.com/denoland/deno/issues/726 is completed.
// Note: this is a keep-alive server. // Note: this is a keep-alive server.
// deno-lint-ignore-file no-console
const addr = Deno.args[0] || "127.0.0.1:4500"; const addr = Deno.args[0] || "127.0.0.1:4500";
const [hostname, port] = addr.split(":"); const [hostname, port] = addr.split(":");
const listener = Deno.listen({ hostname, port: Number(port) }); const listener = Deno.listen({ hostname, port: Number(port) });

View file

@ -1,4 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"
? Deno.args ? Deno.args

View file

@ -1,4 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"
? Deno.args ? Deno.args
: [process.argv[2], process.argv[3]]; : [process.argv[2], process.argv[3]];

View file

@ -2,6 +2,8 @@
// //
// From https://github.com/just-js/benchmarks/tree/main/01-stdio // From https://github.com/just-js/benchmarks/tree/main/01-stdio
// deno-lint-ignore-file no-console
const blocksize = parseInt(Deno.args[0] || 65536); const blocksize = parseInt(Deno.args[0] || 65536);
const buf = new Uint8Array(blocksize); const buf = new Uint8Array(blocksize);
let size = 0; let size = 0;

View file

@ -1,4 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"
? Deno.args ? Deno.args

View file

@ -1,4 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"
? Deno.args ? Deno.args

View file

@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
// Note: when benchmarking across different Deno version, make sure to clear // Note: when benchmarking across different Deno version, make sure to clear
// the DENO_DIR cache. // the DENO_DIR cache.
let [total, count] = typeof Deno !== "undefined" ? Deno.args : []; let [total, count] = typeof Deno !== "undefined" ? Deno.args : [];

View file

@ -1,4 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"
? Deno.args ? Deno.args

View file

@ -3,15 +3,18 @@
use std::sync::Arc; use std::sync::Arc;
use deno_ast::ModuleSpecifier; use deno_ast::ModuleSpecifier;
use deno_config::glob::FilePatterns;
use deno_config::glob::PathOrPatternSet;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::parking_lot::RwLock; use deno_core::parking_lot::RwLock;
use deno_core::resolve_url_or_path;
use deno_graph::ModuleGraph; use deno_graph::ModuleGraph;
use deno_runtime::colors; use deno_runtime::colors;
use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::deno_permissions::PermissionsContainer;
use crate::args::CliOptions; use crate::args::CliOptions;
use crate::module_loader::ModuleLoadPreparer; use crate::module_loader::ModuleLoadPreparer;
use crate::util::fs::collect_specifiers;
use crate::util::path::is_script_ext;
pub trait ModuleGraphContainer: Clone + 'static { pub trait ModuleGraphContainer: Clone + 'static {
/// Acquires a permit to modify the module graph without other code /// Acquires a permit to modify the module graph without other code
@ -99,24 +102,20 @@ impl MainModuleGraphContainer {
files: &[String], files: &[String],
) -> Result<Vec<ModuleSpecifier>, AnyError> { ) -> Result<Vec<ModuleSpecifier>, AnyError> {
let excludes = self.cli_options.workspace().resolve_config_excludes()?; let excludes = self.cli_options.workspace().resolve_config_excludes()?;
Ok( let include_patterns =
files PathOrPatternSet::from_include_relative_path_or_patterns(
.iter() self.cli_options.initial_cwd(),
.filter_map(|file| { files,
let file_url = )?;
resolve_url_or_path(file, self.cli_options.initial_cwd()).ok()?; let file_patterns = FilePatterns {
if file_url.scheme() != "file" { base: self.cli_options.initial_cwd().to_path_buf(),
return Some(file_url); include: Some(include_patterns),
} exclude: excludes,
// ignore local files that match any of files listed in `exclude` option };
let file_path = file_url.to_file_path().ok()?; collect_specifiers(
if excludes.matches_path(&file_path) { file_patterns,
None self.cli_options.vendor_dir_path().map(ToOwned::to_owned),
} else { |e| is_script_ext(e.path),
Some(file_url)
}
})
.collect::<Vec<_>>(),
) )
} }
} }

View file

@ -803,7 +803,7 @@ fn enhanced_lockfile_error_message(err: &ModuleError) -> Option<String> {
"This could be caused by:\n", "This could be caused by:\n",
" * the lock file may be corrupt\n", " * the lock file may be corrupt\n",
" * the source itself may be corrupt\n\n", " * the source itself may be corrupt\n\n",
"Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server." "Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server."
), ),
package_nv, package_nv,
checksum_err.actual, checksum_err.actual,
@ -824,7 +824,7 @@ fn enhanced_lockfile_error_message(err: &ModuleError) -> Option<String> {
"This could be caused by:\n", "This could be caused by:\n",
" * the lock file may be corrupt\n", " * the lock file may be corrupt\n",
" * the source itself may be corrupt\n\n", " * the source itself may be corrupt\n\n",
"Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server." "Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server."
), ),
specifier, specifier,
checksum_err.actual, checksum_err.actual,

View file

@ -249,7 +249,7 @@ pub async fn get_import_completions(
.collect(); .collect();
let mut is_incomplete = false; let mut is_incomplete = false;
if let Some(import_map) = maybe_import_map { if let Some(import_map) = maybe_import_map {
items.extend(get_base_import_map_completions(import_map)); items.extend(get_base_import_map_completions(import_map, specifier));
} }
if let Some(origin_items) = if let Some(origin_items) =
module_registries.get_origin_completions(&text, &range) module_registries.get_origin_completions(&text, &range)
@ -268,20 +268,20 @@ pub async fn get_import_completions(
/// map as completion items. /// map as completion items.
fn get_base_import_map_completions( fn get_base_import_map_completions(
import_map: &ImportMap, import_map: &ImportMap,
referrer: &ModuleSpecifier,
) -> Vec<lsp::CompletionItem> { ) -> Vec<lsp::CompletionItem> {
import_map import_map
.imports() .entries_for_referrer(referrer)
.keys() .map(|entry| {
.map(|key| {
// for some strange reason, keys that start with `/` get stored in the // for some strange reason, keys that start with `/` get stored in the
// import map as `file:///`, and so when we pull the keys out, we need to // import map as `file:///`, and so when we pull the keys out, we need to
// change the behavior // change the behavior
let mut label = if key.starts_with("file://") { let mut label = if entry.key.starts_with("file://") {
FILE_PROTO_RE.replace(key, "").to_string() FILE_PROTO_RE.replace(entry.key, "").to_string()
} else { } else {
key.to_string() entry.key.to_string()
}; };
let kind = if key.ends_with('/') { let kind = if entry.key.ends_with('/') {
label.pop(); label.pop();
Some(lsp::CompletionItemKind::FOLDER) Some(lsp::CompletionItemKind::FOLDER)
} else { } else {

View file

@ -1491,7 +1491,7 @@ impl ConfigData {
} }
}; };
let resolver = deno_core::unsync::spawn({ let resolver = deno_core::unsync::spawn({
let workspace = member_dir.clone(); let workspace = member_dir.workspace.clone();
let file_fetcher = file_fetcher.cloned(); let file_fetcher = file_fetcher.cloned();
async move { async move {
workspace workspace
@ -1846,7 +1846,12 @@ fn resolve_lockfile_from_workspace(
return None; return None;
} }
}; };
resolve_lockfile_from_path(lockfile_path) let frozen = workspace
.workspace
.root_deno_json()
.and_then(|c| c.to_lock_config().ok().flatten().map(|c| c.frozen()))
.unwrap_or(false);
resolve_lockfile_from_path(lockfile_path, frozen)
} }
fn resolve_node_modules_dir( fn resolve_node_modules_dir(
@ -1875,8 +1880,11 @@ fn resolve_node_modules_dir(
canonicalize_path_maybe_not_exists(&node_modules_dir).ok() canonicalize_path_maybe_not_exists(&node_modules_dir).ok()
} }
fn resolve_lockfile_from_path(lockfile_path: PathBuf) -> Option<CliLockfile> { fn resolve_lockfile_from_path(
match CliLockfile::read_from_path(lockfile_path, false) { lockfile_path: PathBuf,
frozen: bool,
) -> Option<CliLockfile> {
match CliLockfile::read_from_path(lockfile_path, frozen) {
Ok(value) => { Ok(value) => {
if value.filename.exists() { if value.filename.exists() {
if let Ok(specifier) = ModuleSpecifier::from_file_path(&value.filename) if let Ok(specifier) = ModuleSpecifier::from_file_path(&value.filename)

View file

@ -324,7 +324,7 @@ impl ManagedCliNpmResolver {
Ok(path) Ok(path)
} }
/// Resolves the package nv from the provided specifier. /// Resolves the package id from the provided specifier.
pub fn resolve_pkg_id_from_specifier( pub fn resolve_pkg_id_from_specifier(
&self, &self,
specifier: &ModuleSpecifier, specifier: &ModuleSpecifier,

View file

@ -515,6 +515,15 @@ async fn sync_resolution_with_fs(
.add(package.clone(), package_path); .add(package.clone(), package_path);
} }
if let Some(deprecated) = &package.deprecated {
log::info!(
"{} {:?} is deprecated: {}",
crate::colors::yellow("Warning"),
package.id,
crate::colors::gray(deprecated),
);
}
// finally stop showing the progress bar // finally stop showing the progress bar
drop(pb_guard); // explicit for clarity drop(pb_guard); // explicit for clarity
Ok::<_, AnyError>(()) Ok::<_, AnyError>(())

View file

@ -5,6 +5,7 @@ use dashmap::DashMap;
use dashmap::DashSet; use dashmap::DashSet;
use deno_ast::MediaType; use deno_ast::MediaType;
use deno_config::workspace::MappedResolution; use deno_config::workspace::MappedResolution;
use deno_config::workspace::MappedResolutionDiagnostic;
use deno_config::workspace::MappedResolutionError; use deno_config::workspace::MappedResolutionError;
use deno_config::workspace::WorkspaceResolver; use deno_config::workspace::WorkspaceResolver;
use deno_core::anyhow::anyhow; use deno_core::anyhow::anyhow;
@ -21,6 +22,7 @@ use deno_graph::NpmLoadError;
use deno_graph::NpmResolvePkgReqsResult; use deno_graph::NpmResolvePkgReqsResult;
use deno_npm::resolution::NpmResolutionError; use deno_npm::resolution::NpmResolutionError;
use deno_package_json::PackageJsonDepValue; use deno_package_json::PackageJsonDepValue;
use deno_runtime::colors;
use deno_runtime::deno_fs; use deno_runtime::deno_fs;
use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_fs::FileSystem;
use deno_runtime::deno_node::is_builtin_node_module; use deno_runtime::deno_node::is_builtin_node_module;
@ -434,6 +436,7 @@ pub struct CliGraphResolver {
maybe_vendor_specifier: Option<ModuleSpecifier>, maybe_vendor_specifier: Option<ModuleSpecifier>,
found_package_json_dep_flag: AtomicFlag, found_package_json_dep_flag: AtomicFlag,
bare_node_builtins_enabled: bool, bare_node_builtins_enabled: bool,
warned_pkgs: DashSet<PackageReq>,
} }
pub struct CliGraphResolverOptions<'a> { pub struct CliGraphResolverOptions<'a> {
@ -469,6 +472,7 @@ impl CliGraphResolver {
.and_then(|v| ModuleSpecifier::from_directory_path(v).ok()), .and_then(|v| ModuleSpecifier::from_directory_path(v).ok()),
found_package_json_dep_flag: Default::default(), found_package_json_dep_flag: Default::default(),
bare_node_builtins_enabled: options.bare_node_builtins_enabled, bare_node_builtins_enabled: options.bare_node_builtins_enabled,
warned_pkgs: Default::default(),
} }
} }
@ -541,8 +545,23 @@ impl Resolver for CliGraphResolver {
}); });
let result = match result { let result = match result {
Ok(resolution) => match resolution { Ok(resolution) => match resolution {
MappedResolution::Normal(specifier) MappedResolution::Normal {
| MappedResolution::ImportMap(specifier) => { specifier,
maybe_diagnostic,
}
| MappedResolution::ImportMap {
specifier,
maybe_diagnostic,
} => {
if let Some(diagnostic) = maybe_diagnostic {
match &*diagnostic {
MappedResolutionDiagnostic::ConstraintNotMatchedLocalVersion { reference, .. } => {
if self.warned_pkgs.insert(reference.req().clone()) {
log::warn!("{} {}\n at {}", colors::yellow("Warning"), diagnostic, referrer_range);
}
}
}
}
// do sloppy imports resolution if enabled // do sloppy imports resolution if enabled
if let Some(sloppy_imports_resolver) = &self.sloppy_imports_resolver { if let Some(sloppy_imports_resolver) = &self.sloppy_imports_resolver {
Ok( Ok(

View file

@ -552,8 +552,20 @@
}, },
"lock": { "lock": {
"description": "Whether to use a lock file or the path to use for the lock file. Can be overridden by CLI arguments.", "description": "Whether to use a lock file or the path to use for the lock file. Can be overridden by CLI arguments.",
"type": ["string", "boolean"], "type": ["string", "boolean", "object"],
"default": true "default": true,
"properties": {
"path": {
"type": "string",
"description": "The path to use for the lock file.",
"default": "deno.lock"
},
"frozen": {
"type": "boolean",
"description": "Whether to exit with an error if lock file is out of date.",
"default": false
}
}
}, },
"unstable": { "unstable": {
"type": "array", "type": "array",
@ -608,6 +620,13 @@
} }
] ]
}, },
"patch": {
"type": "array",
"items": {
"type": "string"
},
"description": "UNSTABLE: List of relative paths to folders containing JSR packages to use local versions of."
},
"workspace": { "workspace": {
"oneOf": [ "oneOf": [
{ {

View file

@ -227,8 +227,8 @@ impl ModuleLoader for EmbeddedModuleLoader {
) )
} }
}, },
Ok(MappedResolution::Normal(specifier)) Ok(MappedResolution::Normal { specifier, .. })
| Ok(MappedResolution::ImportMap(specifier)) => { | Ok(MappedResolution::ImportMap { specifier, .. }) => {
if let Ok(reference) = if let Ok(reference) =
NpmPackageReqReference::from_specifier(&specifier) NpmPackageReqReference::from_specifier(&specifier)
{ {
@ -622,6 +622,7 @@ pub async fn run(
.jsr_pkgs .jsr_pkgs
.iter() .iter()
.map(|pkg| ResolverWorkspaceJsrPackage { .map(|pkg| ResolverWorkspaceJsrPackage {
is_patch: false, // only used for enhancing the diagnostic, which isn't shown in deno compile
base: root_dir_url.join(&pkg.relative_base).unwrap(), base: root_dir_url.join(&pkg.relative_base).unwrap(),
name: pkg.name.clone(), name: pkg.name.clone(),
version: pkg.version.clone(), version: pkg.version.clone(),

View file

@ -472,7 +472,7 @@ async fn resolve_shim_data(
executable_args.push("--cached-only".to_string()); executable_args.push("--cached-only".to_string());
} }
if flags.frozen_lockfile { if flags.frozen_lockfile.unwrap_or(false) {
executable_args.push("--frozen".to_string()); executable_args.push("--frozen".to_string());
} }

View file

@ -189,20 +189,22 @@ impl<'a> deno_graph::source::Resolver for SloppyImportCaptureResolver<'a> {
.map_err(|err| ResolveError::Other(err.into()))?; .map_err(|err| ResolveError::Other(err.into()))?;
match resolution { match resolution {
deno_config::workspace::MappedResolution::Normal(specifier) deno_config::workspace::MappedResolution::Normal {
| deno_config::workspace::MappedResolution::ImportMap(specifier) => { specifier, ..
match self.sloppy_imports_resolver.resolve(&specifier, mode) {
Some(res) => {
self
.captures
.borrow_mut()
.entry(referrer_range.clone())
.or_insert_with(|| res.clone());
Ok(res.into_specifier())
}
None => Ok(specifier),
}
} }
| deno_config::workspace::MappedResolution::ImportMap {
specifier, ..
} => match self.sloppy_imports_resolver.resolve(&specifier, mode) {
Some(res) => {
self
.captures
.borrow_mut()
.entry(referrer_range.clone())
.or_insert_with(|| res.clone());
Ok(res.into_specifier())
}
None => Ok(specifier),
},
deno_config::workspace::MappedResolution::WorkspaceJsrPackage { deno_config::workspace::MappedResolution::WorkspaceJsrPackage {
.. ..
} }

View file

@ -289,6 +289,17 @@ pub async fn add(
_ => bail!("Failed updating config file due to no object."), _ => bail!("Failed updating config file due to no object."),
}; };
if obj.get_string("importMap").is_some() {
bail!(
concat!(
"`deno add` is not supported when configuration file contains an \"importMap\" field. ",
"Inline the import map into the Deno configuration file.\n",
" at {}",
),
config_specifier
);
}
let mut existing_imports = config_file.existing_imports()?; let mut existing_imports = config_file.existing_imports()?;
let is_npm = config_file.is_npm(); let is_npm = config_file.is_npm();

View file

@ -73,8 +73,8 @@ impl SpecifierUnfurler {
self.workspace_resolver.resolve(specifier, referrer) self.workspace_resolver.resolve(specifier, referrer)
{ {
match resolved { match resolved {
MappedResolution::Normal(specifier) MappedResolution::Normal { specifier, .. }
| MappedResolution::ImportMap(specifier) => Some(specifier), | MappedResolution::ImportMap { specifier, .. } => Some(specifier),
MappedResolution::WorkspaceJsrPackage { pkg_req_ref, .. } => { MappedResolution::WorkspaceJsrPackage { pkg_req_ref, .. } => {
Some(ModuleSpecifier::parse(&pkg_req_ref.to_string()).unwrap()) Some(ModuleSpecifier::parse(&pkg_req_ref.to_string()).unwrap())
} }
@ -443,6 +443,7 @@ mod tests {
Arc::new(ModuleSpecifier::from_directory_path(&cwd).unwrap()), Arc::new(ModuleSpecifier::from_directory_path(&cwd).unwrap()),
Some(import_map), Some(import_map),
vec![ResolverWorkspaceJsrPackage { vec![ResolverWorkspaceJsrPackage {
is_patch: false,
base: ModuleSpecifier::from_directory_path(cwd.join("jsr-package")) base: ModuleSpecifier::from_directory_path(cwd.join("jsr-package"))
.unwrap(), .unwrap(),
name: "@denotest/example".to_string(), name: "@denotest/example".to_string(),

View file

@ -157,6 +157,7 @@ function cron(
const _res = isPromise(result) ? (await result) : result; const _res = isPromise(result) ? (await result) : result;
success = true; success = true;
} catch (error) { } catch (error) {
// deno-lint-ignore no-console
console.error(`Exception in cron handler ${name}`, error); console.error(`Exception in cron handler ${name}`, error);
success = false; success = false;
} }

View file

@ -525,6 +525,7 @@ function mapToCallback(context, callback, onError) {
); );
} }
} catch (error) { } catch (error) {
// deno-lint-ignore no-console
console.error("Exception in onError while handling exception", error); console.error("Exception in onError while handling exception", error);
response = internalServerError(); response = internalServerError();
} }
@ -533,6 +534,7 @@ function mapToCallback(context, callback, onError) {
if (innerRequest?.[_upgraded]) { if (innerRequest?.[_upgraded]) {
// We're done here as the connection has been upgraded during the callback and no longer requires servicing. // We're done here as the connection has been upgraded during the callback and no longer requires servicing.
if (response !== UPGRADE_RESPONSE_SENTINEL) { if (response !== UPGRADE_RESPONSE_SENTINEL) {
// deno-lint-ignore no-console
console.error("Upgrade response was not returned from callback"); console.error("Upgrade response was not returned from callback");
context.close(); context.close();
} }
@ -612,6 +614,7 @@ function serve(arg1, arg2) {
const wantsUnix = ObjectHasOwn(options, "path"); const wantsUnix = ObjectHasOwn(options, "path");
const signal = options.signal; const signal = options.signal;
const onError = options.onError ?? function (error) { const onError = options.onError ?? function (error) {
// deno-lint-ignore no-console
console.error(error); console.error(error);
return internalServerError(); return internalServerError();
}; };
@ -627,6 +630,7 @@ function serve(arg1, arg2) {
if (options.onListen) { if (options.onListen) {
options.onListen(listener.addr); options.onListen(listener.addr);
} else { } else {
// deno-lint-ignore no-console
console.log(`Listening on ${path}`); console.log(`Listening on ${path}`);
} }
}); });
@ -684,6 +688,7 @@ function serve(arg1, arg2) {
const host = StringPrototypeIncludes(addr.hostname, ":") const host = StringPrototypeIncludes(addr.hostname, ":")
? `[${addr.hostname}]` ? `[${addr.hostname}]`
: addr.hostname; : addr.hostname;
// deno-lint-ignore no-console
console.log(`Listening on ${scheme}${host}:${addr.port}/`); console.log(`Listening on ${scheme}${host}:${addr.port}/`);
} }
}; };
@ -729,6 +734,7 @@ function serveHttpOn(context, addr, callback) {
const promiseErrorHandler = (error) => { const promiseErrorHandler = (error) => {
// Abnormal exit // Abnormal exit
// deno-lint-ignore no-console
console.error( console.error(
"Terminating Deno.serve loop due to unexpected error", "Terminating Deno.serve loop due to unexpected error",
error, error,
@ -856,6 +862,7 @@ function registerDeclarativeServer(exports) {
const nThreads = serveWorkerCount > 1 const nThreads = serveWorkerCount > 1
? ` with ${serveWorkerCount} threads` ? ` with ${serveWorkerCount} threads`
: ""; : "";
// deno-lint-ignore no-console
console.debug( console.debug(
`%cdeno serve%c: Listening on %chttp://${hostname}:${port}/%c${nThreads}`, `%cdeno serve%c: Listening on %chttp://${hostname}:${port}/%c${nThreads}`,
"color: green", "color: green",

View file

@ -318,6 +318,7 @@ class Kv {
const _res = isPromise(result) ? (await result) : result; const _res = isPromise(result) ? (await result) : result;
success = true; success = true;
} catch (error) { } catch (error) {
// deno-lint-ignore no-console
console.error("Exception in queue handler", error); console.error("Exception in queue handler", error);
} finally { } finally {
const promise: Promise<void> = op_kv_finish_dequeued_message( const promise: Promise<void> = op_kv_finish_dequeued_message(

View file

@ -33,9 +33,12 @@ const UDP_DGRAM_MAXSIZE = 65507;
const { const {
Error, Error,
Number, Number,
NumberIsNaN,
NumberIsInteger,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
ObjectDefineProperty, ObjectDefineProperty,
PromiseResolve, PromiseResolve,
RangeError,
SafeSet, SafeSet,
SetPrototypeAdd, SetPrototypeAdd,
SetPrototypeDelete, SetPrototypeDelete,
@ -531,10 +534,11 @@ const listenOptionApiName = Symbol("listenOptionApiName");
function listen(args) { function listen(args) {
switch (args.transport ?? "tcp") { switch (args.transport ?? "tcp") {
case "tcp": { case "tcp": {
const port = validatePort(args.port);
const { 0: rid, 1: addr } = op_net_listen_tcp( const { 0: rid, 1: addr } = op_net_listen_tcp(
{ {
hostname: args.hostname ?? "0.0.0.0", hostname: args.hostname ?? "0.0.0.0",
port: Number(args.port), port,
}, },
args.reusePort, args.reusePort,
args.loadBalanced ?? false, args.loadBalanced ?? false,
@ -558,14 +562,33 @@ function listen(args) {
} }
} }
function validatePort(maybePort) {
if (typeof maybePort !== "number" && typeof maybePort !== "string") {
throw new TypeError(`Invalid port (expected number): ${maybePort}`);
}
if (maybePort === "") throw new TypeError("Invalid port: ''");
const port = Number(maybePort);
if (!NumberIsInteger(port)) {
if (NumberIsNaN(port) && !NumberIsNaN(maybePort)) {
throw new TypeError(`Invalid port: '${maybePort}'`);
} else {
throw new TypeError(`Invalid port: ${maybePort}`);
}
} else if (port < 0 || port > 65535) {
throw new RangeError(`Invalid port (out of range): ${maybePort}`);
}
return port;
}
function createListenDatagram(udpOpFn, unixOpFn) { function createListenDatagram(udpOpFn, unixOpFn) {
return function listenDatagram(args) { return function listenDatagram(args) {
switch (args.transport) { switch (args.transport) {
case "udp": { case "udp": {
const port = validatePort(args.port);
const { 0: rid, 1: addr } = udpOpFn( const { 0: rid, 1: addr } = udpOpFn(
{ {
hostname: args.hostname ?? "127.0.0.1", hostname: args.hostname ?? "127.0.0.1",
port: args.port, port,
}, },
args.reuseAddress ?? false, args.reuseAddress ?? false,
args.loopback ?? false, args.loopback ?? false,
@ -590,10 +613,11 @@ function createListenDatagram(udpOpFn, unixOpFn) {
async function connect(args) { async function connect(args) {
switch (args.transport ?? "tcp") { switch (args.transport ?? "tcp") {
case "tcp": { case "tcp": {
const port = validatePort(args.port);
const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_connect_tcp( const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_connect_tcp(
{ {
hostname: args.hostname ?? "127.0.0.1", hostname: args.hostname ?? "127.0.0.1",
port: args.port, port,
}, },
); );
localAddr.transport = "tcp"; localAddr.transport = "tcp";
@ -626,4 +650,5 @@ export {
shutdown, shutdown,
TcpConn, TcpConn,
UnixConn, UnixConn,
validatePort,
}; };

View file

@ -17,13 +17,12 @@ import {
op_tls_start, op_tls_start,
} from "ext:core/ops"; } from "ext:core/ops";
const { const {
Number,
ObjectDefineProperty, ObjectDefineProperty,
TypeError, TypeError,
SymbolFor, SymbolFor,
} = primordials; } = primordials;
import { Conn, Listener } from "ext:deno_net/01_net.js"; import { Conn, Listener, validatePort } from "ext:deno_net/01_net.js";
class TlsConn extends Conn { class TlsConn extends Conn {
#rid = 0; #rid = 0;
@ -259,6 +258,7 @@ function listenTls({
if (transport !== "tcp") { if (transport !== "tcp") {
throw new TypeError(`Unsupported transport: '${transport}'`); throw new TypeError(`Unsupported transport: '${transport}'`);
} }
port = validatePort(port);
if (!hasTlsKeyPairOptions(arguments[0])) { if (!hasTlsKeyPairOptions(arguments[0])) {
throw new TypeError( throw new TypeError(
@ -267,7 +267,7 @@ function listenTls({
} }
const keyPair = loadTlsKeyPair("Deno.listenTls", arguments[0]); const keyPair = loadTlsKeyPair("Deno.listenTls", arguments[0]);
const { 0: rid, 1: localAddr } = op_net_listen_tls( const { 0: rid, 1: localAddr } = op_net_listen_tls(
{ hostname, port: Number(port) }, { hostname, port },
{ alpnProtocols, reusePort }, { alpnProtocols, reusePort },
keyPair, keyPair,
); );

View file

@ -42,6 +42,7 @@ export function warnNotImplemented(msg?: string) {
const message = msg const message = msg
? `Warning: Not implemented: ${msg}` ? `Warning: Not implemented: ${msg}`
: "Warning: Not implemented"; : "Warning: Not implemented";
// deno-lint-ignore no-console
console.warn(message); console.warn(message);
} }

View file

@ -906,7 +906,7 @@ class ClientRequest extends OutgoingMessage {
// https://www.rfc-editor.org/rfc/rfc6266#section-4.3 // https://www.rfc-editor.org/rfc/rfc6266#section-4.3
// Refs: https://github.com/nodejs/node/pull/46528 // Refs: https://github.com/nodejs/node/pull/46528
if (isContentDispositionField(key) && this._contentLength) { if (isContentDispositionField(key) && this._contentLength) {
value = Buffer.from(value, "latin1"); value = Buffer.from(value).toString("latin1");
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
@ -1836,6 +1836,7 @@ export class ServerImpl extends EventEmitter {
} }
setTimeout() { setTimeout() {
// deno-lint-ignore no-console
console.error("Not implemented: Server.setTimeout()"); console.error("Not implemented: Server.setTimeout()");
} }

View file

@ -127,6 +127,7 @@ type Http2Headers = Record<string, string | string[]>;
const debugHttp2Enabled = false; const debugHttp2Enabled = false;
function debugHttp2(...args) { function debugHttp2(...args) {
if (debugHttp2Enabled) { if (debugHttp2Enabled) {
// deno-lint-ignore no-console
console.log(...args); console.log(...args);
} }
} }
@ -1636,16 +1637,19 @@ export class Http2Server extends Server {
this.emit("stream", stream, headers); this.emit("stream", stream, headers);
return await stream._deferred.promise; return await stream._deferred.promise;
} catch (e) { } catch (e) {
// deno-lint-ignore no-console
console.log(">>> Error in serveHttpOnConnection", e); console.log(">>> Error in serveHttpOnConnection", e);
} }
return new Response(""); return new Response("");
}, },
() => { () => {
// deno-lint-ignore no-console
console.log(">>> error"); console.log(">>> error");
}, },
() => {}, () => {},
); );
} catch (e) { } catch (e) {
// deno-lint-ignore no-console
console.log(">>> Error in Http2Server", e); console.log(">>> Error in Http2Server", e);
} }
}, },

View file

@ -55,7 +55,6 @@ import process from "node:process";
import { StringPrototypeSlice } from "ext:deno_node/internal/primordials.mjs"; import { StringPrototypeSlice } from "ext:deno_node/internal/primordials.mjs";
import { StreamBase } from "ext:deno_node/internal_binding/stream_wrap.ts"; import { StreamBase } from "ext:deno_node/internal_binding/stream_wrap.ts";
import { Pipe, socketType } from "ext:deno_node/internal_binding/pipe_wrap.ts"; import { Pipe, socketType } from "ext:deno_node/internal_binding/pipe_wrap.ts";
import console from "node:console";
import { Socket } from "node:net"; import { Socket } from "node:net";
export function mapValues<T, O>( export function mapValues<T, O>(
@ -1387,7 +1386,6 @@ export function setupChannel(target: any, ipc: number) {
if (!target.connected) { if (!target.connected) {
const err = new ERR_IPC_CHANNEL_CLOSED(); const err = new ERR_IPC_CHANNEL_CLOSED();
if (typeof callback === "function") { if (typeof callback === "function") {
console.error("ChildProcess.send with callback");
process.nextTick(callback, err); process.nextTick(callback, err);
} else { } else {
nextTick(() => target.emit("error", err)); nextTick(() => target.emit("error", err));

View file

@ -30,6 +30,7 @@ export function initializeDebugEnv(debugEnv: string) {
// NODE_DEBUG=http or NODE_DEBUG=http2. // NODE_DEBUG=http or NODE_DEBUG=http2.
function emitWarningIfNeeded(set: string) { function emitWarningIfNeeded(set: string) {
if ("HTTP" === set || "HTTP2" === set) { if ("HTTP" === set || "HTTP2" === set) {
// deno-lint-ignore no-console
console.warn( console.warn(
"Setting the NODE_DEBUG environment variable " + "Setting the NODE_DEBUG environment variable " +
"to '" + set.toLowerCase() + "' can expose sensitive " + "to '" + set.toLowerCase() + "' can expose sensitive " +
@ -50,6 +51,7 @@ function debuglogImpl(
emitWarningIfNeeded(set); emitWarningIfNeeded(set);
debugImpls[set] = function debug(...args: unknown[]) { debugImpls[set] = function debug(...args: unknown[]) {
const msg = args.map((arg) => inspect(arg)).join(" "); const msg = args.map((arg) => inspect(arg)).join(" ");
// deno-lint-ignore no-console
console.error("%s %s: %s", set, String(Deno.pid), msg); console.error("%s %s: %s", set, String(Deno.pid), msg);
}; };
} else { } else {

View file

@ -28,6 +28,7 @@ class NodeTestContext {
} }
diagnostic(message) { diagnostic(message) {
// deno-lint-ignore no-console
console.log("DIAGNOSTIC:", message); console.log("DIAGNOSTIC:", message);
} }

View file

@ -234,6 +234,7 @@ function timestamp(): string {
*/ */
// deno-lint-ignore no-explicit-any // deno-lint-ignore no-explicit-any
export function log(...args: any[]) { export function log(...args: any[]) {
// deno-lint-ignore no-console
console.log("%s - %s", timestamp(), ReflectApply(format, undefined, args)); console.log("%s - %s", timestamp(), ReflectApply(format, undefined, args));
} }

View file

@ -47,7 +47,7 @@ const {
const debugWorkerThreads = false; const debugWorkerThreads = false;
function debugWT(...args) { function debugWT(...args) {
if (debugWorkerThreads) { if (debugWorkerThreads) {
// deno-lint-ignore prefer-primordials // deno-lint-ignore prefer-primordials no-console
console.log(...args); console.log(...args);
} }
} }

View file

@ -164,6 +164,7 @@ function resolvePromiseWith(value) {
function rethrowAssertionErrorRejection(e) { function rethrowAssertionErrorRejection(e) {
if (e && ObjectPrototypeIsPrototypeOf(AssertionError.prototype, e)) { if (e && ObjectPrototypeIsPrototypeOf(AssertionError.prototype, e)) {
queueMicrotask(() => { queueMicrotask(() => {
// deno-lint-ignore no-console
console.error(`Internal Error: ${e.stack}`); console.error(`Internal Error: ${e.stack}`);
}); });
} }

View file

@ -125,12 +125,15 @@ function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
return; return;
} }
// deno-lint-ignore no-console
const logError = console.error;
if (!verboseDeprecatedApiWarning) { if (!verboseDeprecatedApiWarning) {
if (ALREADY_WARNED_DEPRECATED.has(apiName)) { if (ALREADY_WARNED_DEPRECATED.has(apiName)) {
return; return;
} }
ALREADY_WARNED_DEPRECATED.add(apiName); ALREADY_WARNED_DEPRECATED.add(apiName);
console.error( logError(
`%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2. Run again with DENO_VERBOSE_WARNINGS=1 to get more details.`, `%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2. Run again with DENO_VERBOSE_WARNINGS=1 to get more details.`,
"color: yellow;", "color: yellow;",
"font-weight: bold;", "font-weight: bold;",
@ -176,40 +179,40 @@ function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
} }
ALREADY_WARNED_DEPRECATED.add(apiName + stack); ALREADY_WARNED_DEPRECATED.add(apiName + stack);
console.error( logError(
`%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2.`, `%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2.`,
"color: yellow;", "color: yellow;",
"font-weight: bold;", "font-weight: bold;",
); );
console.error(); logError();
console.error( logError(
"See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations", "See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations",
); );
console.error(); logError();
if (stackLines.length > 0) { if (stackLines.length > 0) {
console.error("Stack trace:"); logError("Stack trace:");
for (let i = 0; i < stackLines.length; i++) { for (let i = 0; i < stackLines.length; i++) {
console.error(` ${StringPrototypeTrim(stackLines[i])}`); logError(` ${StringPrototypeTrim(stackLines[i])}`);
} }
console.error(); logError();
} }
for (let i = 0; i < suggestions.length; i++) { for (let i = 0; i < suggestions.length; i++) {
const suggestion = suggestions[i]; const suggestion = suggestions[i];
console.error( logError(
`%chint: ${suggestion}`, `%chint: ${suggestion}`,
"font-weight: bold;", "font-weight: bold;",
); );
} }
if (isFromRemoteDependency) { if (isFromRemoteDependency) {
console.error( logError(
`%chint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.`, `%chint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.`,
"font-weight: bold;", "font-weight: bold;",
); );
} }
console.error(); logError();
} }
function windowClose() { function windowClose() {
@ -716,25 +719,33 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
if (mode === executionModes.serve) { if (mode === executionModes.serve) {
if (serveIsMain && serveWorkerCount) { if (serveIsMain && serveWorkerCount) {
// deno-lint-ignore no-console
const origLog = console.log; const origLog = console.log;
// deno-lint-ignore no-console
const origError = console.error; const origError = console.error;
const prefix = `[serve-worker-0 ]`; const prefix = `[serve-worker-0 ]`;
// deno-lint-ignore no-console
console.log = (...args) => { console.log = (...args) => {
return origLog(prefix, ...new primordials.SafeArrayIterator(args)); return origLog(prefix, ...new primordials.SafeArrayIterator(args));
}; };
// deno-lint-ignore no-console
console.error = (...args) => { console.error = (...args) => {
return origError(prefix, ...new primordials.SafeArrayIterator(args)); return origError(prefix, ...new primordials.SafeArrayIterator(args));
}; };
} else if (serveWorkerCount !== null) { } else if (serveWorkerCount !== null) {
// deno-lint-ignore no-console
const origLog = console.log; const origLog = console.log;
// deno-lint-ignore no-console
const origError = console.error; const origError = console.error;
const base = `serve-worker-${serveWorkerCount + 1}`; const base = `serve-worker-${serveWorkerCount + 1}`;
// 15 = "serve-worker-nn".length, assuming // 15 = "serve-worker-nn".length, assuming
// serveWorkerCount < 100 // serveWorkerCount < 100
const prefix = `[${StringPrototypePadEnd(base, 15, " ")}]`; const prefix = `[${StringPrototypePadEnd(base, 15, " ")}]`;
// deno-lint-ignore no-console
console.log = (...args) => { console.log = (...args) => {
return origLog(prefix, ...new primordials.SafeArrayIterator(args)); return origLog(prefix, ...new primordials.SafeArrayIterator(args));
}; };
// deno-lint-ignore no-console
console.error = (...args) => { console.error = (...args) => {
return origError(prefix, ...new primordials.SafeArrayIterator(args)); return origError(prefix, ...new primordials.SafeArrayIterator(args));
}; };
@ -757,6 +768,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
if (mode === executionModes.serve && !serve) { if (mode === executionModes.serve && !serve) {
if (serveIsMain) { if (serveIsMain) {
// Only error if main worker // Only error if main worker
// deno-lint-ignore no-console
console.error( console.error(
`%cerror: %cdeno serve requires %cexport default { fetch }%c in the main module, did you mean to run \"deno run\"?`, `%cerror: %cdeno serve requires %cexport default { fetch }%c in the main module, did you mean to run \"deno run\"?`,
"color: yellow;", "color: yellow;",
@ -770,6 +782,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
if (serve) { if (serve) {
if (mode === executionModes.run) { if (mode === executionModes.run) {
// deno-lint-ignore no-console
console.error( console.error(
`%cwarning: %cDetected %cexport default { fetch }%c, did you mean to run \"deno serve\"?`, `%cwarning: %cDetected %cexport default { fetch }%c, did you mean to run \"deno serve\"?`,
"color: yellow;", "color: yellow;",

View file

@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
const targetDir = Deno.execPath().replace(/[^\/\\]+$/, ""); const targetDir = Deno.execPath().replace(/[^\/\\]+$/, "");
const [libPrefix, libSuffix] = { const [libPrefix, libSuffix] = {
darwin: ["lib", "dylib"], darwin: ["lib", "dylib"],

View file

@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
const targetDir = Deno.execPath().replace(/[^\/\\]+$/, ""); const targetDir = Deno.execPath().replace(/[^\/\\]+$/, "");
const [libPrefix, libSuffix] = { const [libPrefix, libSuffix] = {
darwin: ["lib", "dylib"], darwin: ["lib", "dylib"],

View file

@ -282,7 +282,7 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.
", actual_integrity); ", actual_integrity);
test_context test_context
.new_command() .new_command()

View file

@ -1346,23 +1346,27 @@ fn lsp_import_map_import_completions() {
let context = TestContextBuilder::new().use_temp_cwd().build(); let context = TestContextBuilder::new().use_temp_cwd().build();
let temp_dir = context.temp_dir(); let temp_dir = context.temp_dir();
temp_dir.write( temp_dir.write(
"import-map.json", "deno.json",
r#"{ json!({
"imports": { "imports": {
"/~/": "./lib/", "/~/": "./lib/",
"/#/": "./src/", "/#/": "./src/",
"fs": "https://example.com/fs/index.js", "fs": "https://example.com/fs/index.js",
"std/": "https://example.com/std@0.123.0/" "std/": "https://example.com/std@0.123.0/",
} },
}"#, "scopes": {
"file:///": {
"file": "./file.ts",
},
},
})
.to_string(),
); );
temp_dir.create_dir_all("lib"); temp_dir.create_dir_all("lib");
temp_dir.write("lib/b.ts", r#"export const b = "b";"#); temp_dir.write("lib/b.ts", r#"export const b = "b";"#);
let mut client = context.new_lsp_command().build(); let mut client = context.new_lsp_command().build();
client.initialize(|builder| { client.initialize_default();
builder.set_import_map("import-map.json");
});
let uri = temp_dir.uri().join("a.ts").unwrap(); let uri = temp_dir.uri().join("a.ts").unwrap();
@ -1403,6 +1407,13 @@ fn lsp_import_map_import_completions() {
"insertText": "..", "insertText": "..",
"commitCharacters": ["\"", "'"], "commitCharacters": ["\"", "'"],
}, { }, {
"label": "file",
"kind": 17,
"detail": "(import map)",
"sortText": "file",
"insertText": "file",
"commitCharacters": ["\"", "'"],
}, {
"label": "std", "label": "std",
"kind": 19, "kind": 19,
"detail": "(import map)", "detail": "(import map)",

View file

@ -1200,7 +1200,7 @@ fn lock_file_missing_top_level_package() {
"error: failed reading lockfile 'deno.lock'\n", "error: failed reading lockfile 'deno.lock'\n",
"\n", "\n",
"Caused by:\n", "Caused by:\n",
" 0: The lockfile is corrupt. You can recreate it with --lock-write\n", " 0: The lockfile is corrupt. Remove the lockfile to regenerate it.\n",
" 1: Could not find 'cowsay@1.5.0' in the list of packages.\n" " 1: Could not find 'cowsay@1.5.0' in the list of packages.\n"
) )
); );
@ -1483,7 +1483,7 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile at "[WILDCARD]deno.lock". Investigate the lockfile; delete it to regenerate the lockfile at "[WILDCARD]deno.lock".
"#) "#)
.assert_exit_code(10); .assert_exit_code(10);
} }

View file

@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
import { assertEquals, loadTestLibrary } from "./common.js"; import { assertEquals, loadTestLibrary } from "./common.js";
const properties = loadTestLibrary(); const properties = loadTestLibrary();

View file

@ -1,6 +1,8 @@
#!/usr/bin/env -S deno run --allow-read=. --allow-write=. --allow-run=git --config=tests/config/deno.json #!/usr/bin/env -S deno run --allow-read=. --allow-write=. --allow-run=git --config=tests/config/deno.json
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
/** This copies the test files according to the config file `tests/node_compat/config.jsonc` */ /** This copies the test files according to the config file `tests/node_compat/config.jsonc` */
import { walk } from "@std/fs/walk"; import { walk } from "@std/fs/walk";

View file

@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-console
/** /**
* This script will run the test files specified in the configuration file. * This script will run the test files specified in the configuration file.
* *

View file

@ -1,7 +1,5 @@
const assert = require("assert"); const assert = require("assert");
// TODO(kt3k): Uncomment this when util.debuglog is added const debug = require('util').debuglog('test');
// const debug = require('util').debuglog('test');
const debug = console.log;
function onmessage(m) { function onmessage(m) {
debug("CHILD got message:", m); debug("CHILD got message:", m);

View file

@ -0,0 +1,3 @@
export declare function setValue(val: number): void;
export declare function getValue(): number;
export declare const url: string;

View file

@ -0,0 +1,11 @@
let value = 0;
export function setValue(newValue) {
value = newValue;
}
export function getValue() {
return value;
}
export const url = import.meta.url;

View file

@ -0,0 +1,9 @@
{
"name": "@denotest/deprecated-package",
"version": "1.0.0",
"type": "module",
"main": "main.mjs",
"types": "main.d.mts",
"deprecated": "Deprecated version"
}

View file

@ -0,0 +1,5 @@
{
"args": "add jsr:@denotest/add",
"output": "add.out",
"exitCode": 1
}

View file

@ -0,0 +1,2 @@
error: `deno add` is not supported when configuration file contains an "importMap" field. Inline the import map into the Deno configuration file.
at file:///[WILDLINE]/deno.json

View file

@ -0,0 +1,3 @@
{
"importMap": "./import_map.json"
}

View file

@ -0,0 +1 @@
{}

View file

@ -9,4 +9,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -0,0 +1,5 @@
{
"args": "cache *.ts",
"output": "Download http://localhost:4545/echo.ts\n",
"exitCode": 0
}

View file

@ -0,0 +1 @@
import "http://localhost:4545/non-existent.ts";

1
tests/specs/cache/globbing/main.ts vendored Normal file
View file

@ -0,0 +1 @@
import "http://localhost:4545/echo.ts";

View file

@ -0,0 +1,24 @@
{
"tests": {
"star": {
"args": "check *.ts",
"output": "Check [WILDLINE]main.ts\n",
"exitCode": 0
},
"star_not_found": {
"args": "check *.js",
"output": "Warning No matching files found.\n",
"exitCode": 0
},
"glob_star": {
"args": "check **/*.ts",
"output": "Check [WILDLINE]main.ts\nCheck [WILDLINE]sub_dir/main.ts\nerror: TS2322[WILDCARD]",
"exitCode": 1
},
"sub_dir": {
"args": "check sub_dir",
"output": "Check [WILDLINE]sub_dir/main.ts\nerror: TS2322[WILDCARD]",
"exitCode": 1
}
}
}

View file

View file

@ -0,0 +1 @@
console.log("globbing_support_done");

View file

@ -0,0 +1 @@
const value: number = "";

View file

@ -0,0 +1,22 @@
{
"tempDir": true,
"steps": [{
"if": "unix",
"args": "compile --output my-app main/main.ts",
"output": "[WILDCARD]"
}, {
"if": "unix",
"commandName": "./my-app",
"args": [],
"output": "main.out"
}, {
"if": "windows",
"args": "compile --output my-app.exe main/main.ts",
"output": "[WILDCARD]"
}, {
"if": "windows",
"commandName": "./my-app.exe",
"args": [],
"output": "main.out"
}]
}

View file

@ -0,0 +1,4 @@
{
"name": "@denotest/add",
"exports": "./mod.ts"
}

View file

@ -0,0 +1,3 @@
export function add(a: number, b: number): number {
return (a + b) * 2; // it adds wrong
}

View file

@ -0,0 +1 @@
6

View file

@ -0,0 +1,5 @@
{
"patch": [
"../add"
]
}

View file

@ -0,0 +1,3 @@
import { add } from "jsr:@denotest/add";
console.log(add(1, 2));

View file

@ -1,2 +1,2 @@
error: Integrity check failed for package: "npm:@denotest/esm-basic@1.0.0".[WILDCARD] error: Integrity check failed for package: "npm:@denotest/esm-basic@1.0.0".[WILDCARD]
Use the --lock-write flag to regenerate the lockfile at [WILDCARD] Investigate the lockfile; delete it to regenerate the lockfile at [WILDCARD]

View file

@ -0,0 +1,25 @@
{
"tempDir": true,
"envs": {
"DENO_FUTURE": "1"
},
"steps": [
{
"args": "install npm:@denotest/deprecated-package",
"output": "install.out"
},
{
// make sure the dep got cached
"args": "run --cached-only main.js",
"exitCode": 0,
"output": ""
},
{
"args": [
"eval",
"console.log(Deno.readTextFileSync('package.json').trim())"
],
"output": "package.json.out"
}
]
}

View file

@ -0,0 +1,5 @@
Add npm:@denotest/deprecated-package@1.0.0
Download http://localhost:4260/@denotest/deprecated-package
Download http://localhost:4260/@denotest/deprecated-package/1.0.0.tgz
Initialize @denotest/deprecated-package@1.0.0
Warning @denotest/deprecated-package@1.0.0 is deprecated: Deprecated version

View file

@ -0,0 +1,2 @@
import { setValue } from "@denotest/deprecated-package";
setValue(5);

View file

@ -0,0 +1,3 @@
{
"dependencies": {}
}

View file

@ -0,0 +1,3 @@
{
"dependencies": { "@denotest/deprecated-package": "^1.0.0" }
}

View file

@ -10,4 +10,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -9,4 +9,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -8,4 +8,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -8,4 +8,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -8,4 +8,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -123,6 +123,35 @@
} }
] ]
}, },
"lockfile_config": {
"steps": [
{
"args": [
"eval",
"Deno.writeTextFileSync('deno.json', JSON.stringify({ lock: { frozen: true }, ...JSON.parse(Deno.readTextFileSync('deno.json')) }))"
],
"output": ""
},
{
"args": "cache --frozen=false add.ts",
"output": "[WILDCARD]"
},
{
// sub.ts imports from an npm package
// that's not in the lockfile
"args": "run sub.ts",
"output": "frozen_new_dep_run.out",
"exitCode": 1
},
{
"args": "cache sub.ts",
"output": "frozen_new_dep_cache.out",
"exitCode": 1
}
]
},
"non_analyzable_dynamic_npm": { "non_analyzable_dynamic_npm": {
"steps": [ "steps": [
{ {

View file

@ -8,4 +8,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -8,4 +8,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -9,4 +9,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -8,4 +8,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -8,4 +8,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -9,4 +9,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -9,4 +9,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -53,6 +53,8 @@ struct MultiTestMetaData {
#[serde(default)] #[serde(default)]
pub envs: HashMap<String, String>, pub envs: HashMap<String, String>,
#[serde(default)] #[serde(default)]
pub cwd: Option<String>,
#[serde(default)]
pub tests: BTreeMap<String, JsonMap>, pub tests: BTreeMap<String, JsonMap>,
} }
@ -73,6 +75,10 @@ impl MultiTestMetaData {
if multi_test_meta_data.temp_dir && !value.contains_key("tempDir") { if multi_test_meta_data.temp_dir && !value.contains_key("tempDir") {
value.insert("tempDir".to_string(), true.into()); value.insert("tempDir".to_string(), true.into());
} }
if multi_test_meta_data.cwd.is_some() && !value.contains_key("cwd") {
value
.insert("cwd".to_string(), multi_test_meta_data.cwd.clone().into());
}
if !multi_test_meta_data.envs.is_empty() { if !multi_test_meta_data.envs.is_empty() {
if !value.contains_key("envs") { if !value.contains_key("envs") {
value.insert("envs".to_string(), JsonMap::default().into()); value.insert("envs".to_string(), JsonMap::default().into());
@ -112,6 +118,8 @@ struct MultiStepMetaData {
#[serde(default)] #[serde(default)]
pub base: Option<String>, pub base: Option<String>,
#[serde(default)] #[serde(default)]
pub cwd: Option<String>,
#[serde(default)]
pub envs: HashMap<String, String>, pub envs: HashMap<String, String>,
#[serde(default)] #[serde(default)]
pub repeat: Option<usize>, pub repeat: Option<usize>,
@ -136,6 +144,7 @@ impl SingleTestMetaData {
pub fn into_multi(self) -> MultiStepMetaData { pub fn into_multi(self) -> MultiStepMetaData {
MultiStepMetaData { MultiStepMetaData {
base: self.base, base: self.base,
cwd: None,
temp_dir: self.temp_dir, temp_dir: self.temp_dir,
repeat: self.repeat, repeat: self.repeat,
envs: Default::default(), envs: Default::default(),
@ -371,7 +380,7 @@ fn run_step(
VecOrString::Vec(args) => command.args_vec(args), VecOrString::Vec(args) => command.args_vec(args),
VecOrString::String(text) => command.args(text), VecOrString::String(text) => command.args(text),
}; };
let command = match &step.cwd { let command = match step.cwd.as_ref().or(metadata.cwd.as_ref()) {
Some(cwd) => command.current_dir(cwd), Some(cwd) => command.current_dir(cwd),
None => command, None => command,
}; };

View file

@ -9,4 +9,4 @@ This could be caused by:
* the lock file may be corrupt * the lock file may be corrupt
* the source itself may be corrupt * the source itself may be corrupt
Use the --lock-write flag to regenerate the lockfile at "[WILDCARD]lock.json". Investigate the lockfile; delete it to regenerate the lockfile at "[WILDCARD]lock.json".

View file

@ -0,0 +1,25 @@
{
"tempDir": true,
"tests": {
"matching_version": {
"cwd": "./my-pkg",
"steps": [{
"args": "test",
"output": "test.out"
}, {
"args": "lint",
"output": "Checked 2 files\n"
}]
},
"not_matching_version": {
"steps": [{
"args": "run --allow-read=. --allow-write=. modify_version.ts",
"output": "[WILDCARD]"
}, {
"cwd": "./my-pkg",
"args": "test",
"output": "not_matching_version.out"
}]
}
}
}

View file

@ -0,0 +1,5 @@
{
"name": "@denotest/add",
"version": "1.0.0",
"exports": "./mod.ts"
}

View file

@ -0,0 +1,9 @@
import { add } from "./mod.ts";
// this test should not be run or linted
Deno.test("add", () => {
let unusedVar = 5; // purposefully causing a lint error to ensure it's not linted
if (add(1, 2) !== 3) {
throw new Error("fail");
}
});

Some files were not shown because too many files have changed in this diff Show more