Split up and document isLocal

This commit is contained in:
Michael B. Gale
2026-07-14 22:24:05 +01:00
parent 7ec982acb7
commit 3b749300ae
2 changed files with 41 additions and 5 deletions

10
lib/entry-points.js generated
View File

@@ -149707,11 +149707,17 @@ async function initConfig(actionState, inputs) {
await setCppTrapCachingEnvironmentVariables(config, logger);
return config;
}
function isRelativePath(configPath) {
return configPath.startsWith("./");
}
function containsAtRef(configPath) {
return configPath.includes("@");
}
function isLocal(configPath) {
if (configPath.indexOf("./") === 0) {
if (isRelativePath(configPath)) {
return true;
}
return configPath.indexOf("@") === -1;
return !containsAtRef(configPath);
}
function getLocalConfig(logger, configFile, validateConfig) {
if (!fs9.existsSync(configFile)) {

View File

@@ -1277,13 +1277,43 @@ export async function initConfig(
return config;
}
/**
* 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.
*
* @param configPath The path to test.
*/
function isRelativePath(configPath: string): boolean {
return configPath.startsWith("./");
}
/**
* Determines if `configPath` contains a '@' character.
*
* @param configPath The path to test.
*/
function containsAtRef(configPath: string): boolean {
return configPath.includes("@");
}
/**
* Determines if `configPath` refers to a local configuration file.
* This assumes the `OLD_REMOTE_ADDRESS_FORMAT` which must contain a '@'
* character for remote addresses.
*
* @param configPath The path to test.
* @returns True if it is local, or false otherwise.
*/
function isLocal(configPath: string): boolean {
// If the path starts with ./, look locally
if (configPath.indexOf("./") === 0) {
// If the path starts with "./", it is explicitly local.
// This allows local paths that would otherwise contain '@'
// to be used with a "./" prefix.
if (isRelativePath(configPath)) {
return true;
}
return configPath.indexOf("@") === -1;
// Otherwise, the path is also local if it does not contain '@'.
return !containsAtRef(configPath);
}
export function getLocalConfig(