Move the local path prefix into a constant

This commit is contained in:
Michael B. Gale
2026-07-15 15:56:14 +01:00
parent 6d3bde3729
commit 001d4ae610
3 changed files with 13 additions and 7 deletions

3
lib/entry-points.js generated
View File

@@ -148352,6 +148352,7 @@ async function parseRemoteFileAddress(actionState, configFile) {
}
// src/config/file.ts
var LOCAL_PATH_PREFIX = "./";
async function getConfigFileInput({
logger,
actions,
@@ -149713,7 +149714,7 @@ async function initConfig(actionState, inputs) {
return config;
}
function isRelativePath(configPath) {
return configPath.startsWith("./");
return configPath.startsWith(LOCAL_PATH_PREFIX);
}
function containsAtRef(configPath) {
return configPath.includes("@");

View File

@@ -31,7 +31,7 @@ import {
parseUserConfig,
UserConfig,
} from "./config/db-config";
import { getRemoteConfig } from "./config/file";
import { getRemoteConfig, LOCAL_PATH_PREFIX } from "./config/file";
import {
parseRegistries,
type RegistryConfigNoCredentials,
@@ -1278,13 +1278,13 @@ export async function initConfig(
}
/**
* Determines if `configPath` is explicitly local. That is, it starts with "./".
* A configuration file path that starts with "./" is always treated as a local path.
* Determines if `configPath` is explicitly local. That is, it starts with `LOCAL_PATH_PREFIX`.
* A configuration file path that starts with `LOCAL_PATH_PREFIX` is always treated as a local path.
*
* @param configPath The path to test.
*/
function isRelativePath(configPath: string): boolean {
return configPath.startsWith("./");
return configPath.startsWith(LOCAL_PATH_PREFIX);
}
/**
@@ -1305,9 +1305,9 @@ function containsAtRef(configPath: string): boolean {
* @returns True if it is local, or false otherwise.
*/
function isLocal(configPath: string): boolean {
// If the path starts with "./", it is explicitly local.
// If the path starts with `LOCAL_PATH_PREFIX`, it is explicitly local.
// This allows local paths that would otherwise contain '@'
// to be used with a "./" prefix.
// to be used with a `LOCAL_PATH_PREFIX` prefix.
if (isRelativePath(configPath)) {
return true;
}

View File

@@ -11,6 +11,11 @@ import { ConfigurationError } from "../util";
import { parseUserConfig, UserConfig } from "./db-config";
import { parseRemoteFileAddress } from "./remote-file";
/**
* The prefix that can be specified to indicate that a path should be treated as a local file address.
*/
export const LOCAL_PATH_PREFIX = "./";
/**
* Gets the value that is configured for the configuration file, if any.
*/