Skip to content

Commit 001d4ae

Browse files
committed
Move the local path prefix into a constant
1 parent 6d3bde3 commit 001d4ae

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

lib/entry-points.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
parseUserConfig,
3232
UserConfig,
3333
} from "./config/db-config";
34-
import { getRemoteConfig } from "./config/file";
34+
import { getRemoteConfig, LOCAL_PATH_PREFIX } from "./config/file";
3535
import {
3636
parseRegistries,
3737
type RegistryConfigNoCredentials,
@@ -1278,13 +1278,13 @@ export async function initConfig(
12781278
}
12791279

12801280
/**
1281-
* Determines if `configPath` is explicitly local. That is, it starts with "./".
1282-
* A configuration file path that starts with "./" is always treated as a local path.
1281+
* Determines if `configPath` is explicitly local. That is, it starts with `LOCAL_PATH_PREFIX`.
1282+
* A configuration file path that starts with `LOCAL_PATH_PREFIX` is always treated as a local path.
12831283
*
12841284
* @param configPath The path to test.
12851285
*/
12861286
function isRelativePath(configPath: string): boolean {
1287-
return configPath.startsWith("./");
1287+
return configPath.startsWith(LOCAL_PATH_PREFIX);
12881288
}
12891289

12901290
/**
@@ -1305,9 +1305,9 @@ function containsAtRef(configPath: string): boolean {
13051305
* @returns True if it is local, or false otherwise.
13061306
*/
13071307
function isLocal(configPath: string): boolean {
1308-
// If the path starts with "./", it is explicitly local.
1308+
// If the path starts with `LOCAL_PATH_PREFIX`, it is explicitly local.
13091309
// This allows local paths that would otherwise contain '@'
1310-
// to be used with a "./" prefix.
1310+
// to be used with a `LOCAL_PATH_PREFIX` prefix.
13111311
if (isRelativePath(configPath)) {
13121312
return true;
13131313
}

src/config/file.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { ConfigurationError } from "../util";
1111
import { parseUserConfig, UserConfig } from "./db-config";
1212
import { parseRemoteFileAddress } from "./remote-file";
1313

14+
/**
15+
* The prefix that can be specified to indicate that a path should be treated as a local file address.
16+
*/
17+
export const LOCAL_PATH_PREFIX = "./";
18+
1419
/**
1520
* Gets the value that is configured for the configuration file, if any.
1621
*/

0 commit comments

Comments
 (0)