@@ -39,7 +39,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3939 });
4040};
4141Object.defineProperty(exports, "__esModule", ({ value: true }));
42- exports.runCleanup = exports.runAction = exports.forceUseCache = exports.getContainerId = exports.runCompose = exports.ComposeError = void 0;
42+ exports.runCleanup = exports.runAction = exports.forceUseCache = exports.getContainerId = exports.runCompose = exports.composeCommand = exports. ComposeError = void 0;
4343const core = __importStar(__nccwpck_require__(2186));
4444const exec = __importStar(__nccwpck_require__(1514));
4545const transform_1 = __nccwpck_require__(1644);
@@ -50,6 +50,42 @@ class ComposeError extends Error {
5050 }
5151}
5252exports.ComposeError = ComposeError;
53+ class ComposeCommand {
54+ constructor() {
55+ // Not using a constructor as the singleton implementation due to await, constructors can't be async.
56+ this.initialised = false;
57+ this.composeCommand = 'docker-compose';
58+ }
59+ /**
60+ * Checks docker-compose availability, using docker compose as fallback.
61+ *
62+ * @returns {Promise<string>} 'docker-compose' or 'docker compose'
63+ */
64+ get() {
65+ return __awaiter(this, void 0, void 0, function* () {
66+ if (!this.initialised) {
67+ this.initialised = true;
68+ try {
69+ yield exec.exec('docker-compose', ['--version']);
70+ }
71+ catch (error) {
72+ console.warn('docker-compose not available, falling back to docker compose');
73+ this.composeCommand = 'docker compose';
74+ }
75+ }
76+ return this.composeCommand;
77+ });
78+ }
79+ init() {
80+ this.initialised = true;
81+ this.composeCommand = 'docker-compose';
82+ }
83+ reset() {
84+ this.initialised = false;
85+ this.composeCommand = 'docker-compose';
86+ }
87+ }
88+ exports.composeCommand = new ComposeCommand();
5389function runCompose(command, args, context, execOptions) {
5490 return __awaiter(this, void 0, void 0, function* () {
5591 const composeArgs = [];
@@ -63,7 +99,8 @@ function runCompose(command, args, context, execOptions) {
6399 for (const part of args) {
64100 composeArgs.push(part);
65101 }
66- return yield exec.exec('docker-compose', composeArgs, execOptions);
102+ const dockerCompose = yield exports.composeCommand.get();
103+ return yield exec.exec(dockerCompose, composeArgs, execOptions);
67104 });
68105}
69106exports.runCompose = runCompose;
0 commit comments