mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(npm): probing for files that have a file stem (#16641)
This commit is contained in:
parent
d6fd171394
commit
f2bf40d157
7 changed files with 23 additions and 5 deletions
|
@ -1178,8 +1178,8 @@ fn file_extension_probe(
|
||||||
) -> Result<PathBuf, AnyError> {
|
) -> Result<PathBuf, AnyError> {
|
||||||
let p = p.clean();
|
let p = p.clean();
|
||||||
if p.exists() {
|
if p.exists() {
|
||||||
let mut p_js = p.clone();
|
let file_name = p.file_name().unwrap();
|
||||||
p_js.set_extension("js");
|
let p_js = p.with_file_name(format!("{}.js", file_name.to_str().unwrap()));
|
||||||
if p_js.exists() && p_js.is_file() {
|
if p_js.exists() && p_js.is_file() {
|
||||||
return Ok(p_js);
|
return Ok(p_js);
|
||||||
} else if p.is_dir() {
|
} else if p.is_dir() {
|
||||||
|
@ -1187,9 +1187,8 @@ fn file_extension_probe(
|
||||||
} else {
|
} else {
|
||||||
return Ok(p);
|
return Ok(p);
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(file_name) = p.file_name() {
|
||||||
let mut p_js = p.clone();
|
let p_js = p.with_file_name(format!("{}.js", file_name.to_str().unwrap()));
|
||||||
p_js.set_extension("js");
|
|
||||||
if p_js.exists() && p_js.is_file() {
|
if p_js.exists() && p_js.is_file() {
|
||||||
return Ok(p_js);
|
return Ok(p_js);
|
||||||
}
|
}
|
||||||
|
|
5
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/index.js
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
"use strict";
|
||||||
|
console.log("hello");
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const tslib_1 = require("./tslib.js");
|
||||||
|
tslib_1.__exportStar(require("./other.service"), exports);
|
4
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/other.service.js
vendored
Normal file
4
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/other.service.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.foo = void 0;
|
||||||
|
console.log("world");
|
4
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/package.json
vendored
Normal file
4
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"name": "@denotest/cjs-with-file-stem",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
3
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/tslib.js
vendored
Normal file
3
cli/tests/testdata/npm/registry/@denotest/cjs-with-file-stem/1.0.0/tslib.js
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = {
|
||||||
|
__exportStar: function(mod) {}
|
||||||
|
};
|
|
@ -1,5 +1,6 @@
|
||||||
import fsx from "npm:fs-extra@10.1.0";
|
import fsx from "npm:fs-extra@10.1.0";
|
||||||
import { createApp } from "npm:vue";
|
import { createApp } from "npm:vue";
|
||||||
|
import "npm:@denotest/cjs-with-file-stem";
|
||||||
|
|
||||||
console.log(fsx.access);
|
console.log(fsx.access);
|
||||||
console.log(createApp);
|
console.log(createApp);
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
hello
|
||||||
|
world
|
||||||
[Function: access]
|
[Function: access]
|
||||||
[Function: createApp]
|
[Function: createApp]
|
||||||
|
|
Loading…
Reference in a new issue