Skip to content

Commit be64407

Browse files
committed
Release 2.1.7
1 parent 8c29ff0 commit be64407

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mage-db-sync",
3-
"version": "2.1.6",
3+
"version": "2.1.7",
44
"description": "Database synchronizer for Magento, based on Magerun",
55
"license": "MIT",
66
"author": {

src/services/CommandService.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,36 @@ export class CommandService {
8181

8282
/**
8383
* Check if DDEV is active in current directory
84+
* @param targetDir Optional directory to check (defaults to current working directory)
8485
*/
85-
public async isDdevActive(): Promise<boolean> {
86+
public async isDdevActive(targetDir?: string): Promise<boolean> {
8687
try {
87-
const result = await this.execLocal('ddev', ['status']);
88-
return result.exitCode === 0 && result.stdout.includes('running');
88+
// Use ddev describe with JSON output for reliable parsing
89+
const options = targetDir ? { cwd: targetDir } : {};
90+
const result = await this.execLocal('ddev', ['describe', '-j'], options);
91+
92+
if (result.exitCode !== 0) {
93+
return false;
94+
}
95+
96+
// Parse JSON output to check status
97+
const data = JSON.parse(result.stdout);
98+
99+
// Verify the project exists and is running
100+
if (!data || !data.raw) {
101+
return false;
102+
}
103+
104+
// Check if project is running
105+
const isRunning = data.raw.status === 'running';
106+
107+
// Verify the approot matches the target directory (resolve both to absolute paths)
108+
const path = require('path');
109+
const checkDir = targetDir ? path.resolve(targetDir) : process.cwd();
110+
const approot = data.raw.approot ? path.resolve(data.raw.approot) : null;
111+
112+
// Both must match and project must be running
113+
return isRunning && approot === checkDir;
89114
} catch {
90115
return false;
91116
}

src/tasks/ChecksTask.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,14 @@ class ChecksTask {
194194
task: async (ctx: any, task: any): Promise<boolean> => {
195195
task.output = 'Verifying DDEV is running...';
196196
const commandService = this.services.getCommand();
197-
const isRunning = await commandService.isDdevActive();
197+
198+
// Check DDEV status in the import directory
199+
const importDir = config.settings.currentFolder;
200+
const isRunning = await commandService.isDdevActive(importDir);
198201

199202
if (!isRunning) {
200203
throw UI.createError(
201-
`DDEV project is not running in this directory\n` +
204+
`DDEV project is not running in ${importDir}\n` +
202205
`[TIP] Start your DDEV project with: ddev start`
203206
);
204207
}

0 commit comments

Comments
 (0)