Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/sources/run/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export class RunCommandParser implements SourceParser {

// Parse the arguments
let i = 2; // Skip 'docker' and 'run'
let imageFound = false;
const commandParts: string[] = [];

while (i < parts.length) {
const arg = parts[i];

Expand Down Expand Up @@ -63,16 +66,27 @@ export class RunCommandParser implements SourceParser {
break;

default:
if (!arg.startsWith('-')) {
config.image = parseDockerImage(arg);
// Skip other options
if (arg.startsWith('--')) {
i++; // Skip the value of the option if it exists
}
}
} else {
} else if (!imageFound) {
// First non-option argument is the image
config.image = parseDockerImage(arg);
imageFound = true;
} else {
// Any arguments after the image are part of the command
commandParts.push(arg);
}

i++;
}

// Join the command parts if any were found
if (commandParts.length > 0) {
config.command = commandParts.join(' ');
}

if (environmentOptions) {
const serviceName = 'default'; // Docker run always uses 'default' as service name
Expand Down Expand Up @@ -120,8 +134,6 @@ export class RunCommandParser implements SourceParser {
'default': config
}
};


}

validate(content: string): boolean {
Expand All @@ -145,7 +157,6 @@ export class RunCommandParser implements SourceParser {
for (let i = 0; i < command.length; i++) {
const char = command[i];


if (char === '\'' || char === '"') {
inQuotes = !inQuotes;
continue;
Expand Down