Skip to content

Commit ab11579

Browse files
committed
update
1 parent 04f0e88 commit ab11579

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/TsconfigPathsUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"use strict";
77

88
const path = require("path");
9-
const { join, normalize } = require("./util/path");
9+
const { isAbsolute, join, normalize } = require("./util/path");
1010

1111
/** @typedef {import("./Resolver")} Resolver */
1212
/** @typedef {import("./Resolver").FileSystem} FileSystem */
@@ -237,7 +237,7 @@ async function readTsconfigCompilerOptions(fileSystem, absTsconfigPath) {
237237

238238
if (!baseUrl) {
239239
baseUrl = path.dirname(absTsconfigPath);
240-
} else if (!path.isAbsolute(baseUrl)) {
240+
} else if (!isAbsolute(baseUrl)) {
241241
baseUrl = join(path.dirname(absTsconfigPath), baseUrl);
242242
}
243243

@@ -293,7 +293,7 @@ async function loadTsconfigPathsData(
293293
context = process.cwd(),
294294
) {
295295
try {
296-
const absTsconfigPath = path.isAbsolute(configFile)
296+
const absTsconfigPath = isAbsolute(configFile)
297297
? configFile
298298
: join(context, configFile);
299299

lib/util/path.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ const getType = (maybePath) => {
120120
return PathType.Normal;
121121
};
122122

123+
/**
124+
* @param {string} path a path
125+
* @returns {boolean} true, if path is absolute
126+
*/
127+
const isAbsolute = (path) =>
128+
getType(path) === PathType.AbsolutePosix ||
129+
getType(path) === PathType.AbsoluteWin;
130+
123131
/**
124132
* @param {string} maybePath a path
125133
* @returns {string} the normalized path
@@ -199,5 +207,6 @@ module.exports.cachedJoin = cachedJoin;
199207
module.exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx;
200208
module.exports.getType = getType;
201209
module.exports.invalidSegmentRegEx = invalidSegmentRegEx;
210+
module.exports.isAbsolute = isAbsolute;
202211
module.exports.join = join;
203212
module.exports.normalize = normalize;

0 commit comments

Comments
 (0)