|
@@ -110,6 +110,30 @@ export class Config {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Substitute environment variables in a string
|
|
|
|
|
+ * Replaces ${VAR_NAME} or $VAR_NAME with values from environment
|
|
|
|
|
+ */
|
|
|
|
|
+ substituteEnvVars(str) {
|
|
|
|
|
+ if (!str || typeof str !== 'string') {
|
|
|
|
|
+ return str;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Replace ${VAR_NAME} pattern
|
|
|
|
|
+ str = str.replace(/\$\{([A-Z_][A-Z0-9_]*)\}/g, (match, varName) => {
|
|
|
|
|
+ return this.get(varName, match);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // Replace $VAR_NAME pattern (only at start or after /)
|
|
|
|
|
+ str = str.replace(/(^|\/)(\$[A-Z_][A-Z0-9_]*)/g, (match, prefix, varName) => {
|
|
|
|
|
+ const cleanVarName = varName.substring(1); // Remove $
|
|
|
|
|
+ const value = this.get(cleanVarName);
|
|
|
|
|
+ return value !== undefined ? prefix + value : match;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return str;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Get command configurations for a specific event type
|
|
* Get command configurations for a specific event type
|
|
|
* Returns array of command configs from commands.json, or legacy config from .env
|
|
* Returns array of command configs from commands.json, or legacy config from .env
|
|
@@ -117,7 +141,12 @@ export class Config {
|
|
|
getCommandConfig(eventType) {
|
|
getCommandConfig(eventType) {
|
|
|
// Check if we have JSON commands for this event type
|
|
// Check if we have JSON commands for this event type
|
|
|
if (this.commands.commands && this.commands.commands[eventType]) {
|
|
if (this.commands.commands && this.commands.commands[eventType]) {
|
|
|
- return this.commands.commands[eventType];
|
|
|
|
|
|
|
+ // Substitute environment variables in command paths
|
|
|
|
|
+ return this.commands.commands[eventType].map(cmd => ({
|
|
|
|
|
+ ...cmd,
|
|
|
|
|
+ command: this.substituteEnvVars(cmd.command),
|
|
|
|
|
+ cwd: this.substituteEnvVars(cmd.cwd)
|
|
|
|
|
+ }));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Fallback to .env configuration (for backward compatibility)
|
|
// Fallback to .env configuration (for backward compatibility)
|
|
@@ -150,7 +179,12 @@ export class Config {
|
|
|
getGlobalCommandConfig() {
|
|
getGlobalCommandConfig() {
|
|
|
// Check if we have JSON commands for global
|
|
// Check if we have JSON commands for global
|
|
|
if (this.commands.commands && this.commands.commands.global) {
|
|
if (this.commands.commands && this.commands.commands.global) {
|
|
|
- return this.commands.commands.global;
|
|
|
|
|
|
|
+ // Substitute environment variables in command paths
|
|
|
|
|
+ return this.commands.commands.global.map(cmd => ({
|
|
|
|
|
+ ...cmd,
|
|
|
|
|
+ command: this.substituteEnvVars(cmd.command),
|
|
|
|
|
+ cwd: this.substituteEnvVars(cmd.cwd)
|
|
|
|
|
+ }));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Fallback to .env configuration (for backward compatibility)
|
|
// Fallback to .env configuration (for backward compatibility)
|