mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(install/global): do not error if path is an npm pkg and relative file (#26975)
Closes https://github.com/denoland/deno/issues/26969
This commit is contained in:
parent
566a6c2ce7
commit
6ee8efc5b4
4 changed files with 70 additions and 14 deletions
|
@ -359,6 +359,7 @@ async fn install_global(
|
|||
// ensure the module is cached
|
||||
let factory = CliFactory::from_flags(flags.clone());
|
||||
|
||||
let cli_options = factory.cli_options()?;
|
||||
let http_client = factory.http_client_provider();
|
||||
let deps_http_cache = factory.global_http_cache()?;
|
||||
let mut deps_file_fetcher = FileFetcher::new(
|
||||
|
@ -381,10 +382,11 @@ async fn install_global(
|
|||
));
|
||||
|
||||
let entry_text = install_flags_global.module_url.as_str();
|
||||
let req = super::registry::AddRmPackageReq::parse(entry_text);
|
||||
|
||||
// found a package requirement but missing the prefix
|
||||
if let Ok(Err(package_req)) = req {
|
||||
if !cli_options.initial_cwd().join(entry_text).exists() {
|
||||
// check for package requirement missing prefix
|
||||
if let Ok(Err(package_req)) =
|
||||
super::registry::AddRmPackageReq::parse(entry_text)
|
||||
{
|
||||
if jsr_resolver.req_to_nv(&package_req).await.is_some() {
|
||||
bail!(
|
||||
"{entry_text} is missing a prefix. Did you mean `{}`?",
|
||||
|
@ -397,6 +399,7 @@ async fn install_global(
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
factory
|
||||
.main_module_graph_container()
|
||||
|
|
32
tests/registry/npm/cli.ts/registry.json
Normal file
32
tests/registry/npm/cli.ts/registry.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "cli.ts",
|
||||
"description": "Package with name like a file path",
|
||||
"dist-tags": {
|
||||
"latest": "2.2.0"
|
||||
},
|
||||
"versions": {
|
||||
"2.2.0": {
|
||||
"name": "cli.ts",
|
||||
"version": "2.2.0",
|
||||
"description": "Package with name like a file path",
|
||||
"license": "MIT",
|
||||
"author": {},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"gitHead": "91440c5a1615354fb9419354650937c434eb9f49",
|
||||
"_id": "cli.ts@2.2.0",
|
||||
"_nodeVersion": "10.16.0",
|
||||
"_npmVersion": "6.9.0",
|
||||
"dist": {
|
||||
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
|
||||
"shasum": "ee8472dbb129e727b31e8a10a427dee9dfe4008b",
|
||||
"tarball": "http://localhost:4260/cli.ts/cli.ts-2.2.0.tgz",
|
||||
"fileCount": 5,
|
||||
"unpackedSize": 5508
|
||||
},
|
||||
"directories": {},
|
||||
"_hasShrinkwrap": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"tests": {
|
||||
"file_exists": {
|
||||
"steps": [{
|
||||
"args": ["eval", "Deno.writeTextFileSync('cli.ts', '')"],
|
||||
"output": "[WILDCARD]"
|
||||
}, {
|
||||
// success
|
||||
"args": "install --root ./bins -g --name my-cli cli.ts",
|
||||
"output": "[WILDCARD]"
|
||||
}]
|
||||
},
|
||||
"file_not_exists": {
|
||||
"args": "install --root ./bins -g --name my-cli cli.ts",
|
||||
"output": "file_not_exists.out",
|
||||
"exitCode": 1
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
error: cli.ts is missing a prefix. Did you mean `deno install -g npm:cli.ts`?
|
Loading…
Reference in a new issue