Skip to content

Commit 51eb2cf

Browse files
committed
✨ feat: enhance watch mode for HyvaThemes and MagentoStandard builders
1 parent 47b2529 commit 51eb2cf

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

src/Service/ThemeBuilder/HyvaThemes/Builder.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,19 @@ public function watch(string $themePath, SymfonyStyle $io, OutputInterface $outp
234234
return false;
235235
}
236236

237+
$currentDir = getcwd();
238+
// phpcs:ignore MEQP1.Security.DiscouragedFunction -- chdir is necessary for npm to run in correct context
239+
chdir($tailwindPath);
240+
237241
try {
238-
// phpcs:ignore MEQP1.Security.DiscouragedFunction -- chdir is necessary for npm to run in correct context
239-
chdir($tailwindPath);
240-
passthru('npm run watch');
242+
if ($isVerbose) {
243+
$io->text('Starting watch mode...');
244+
}
245+
$this->shell->execute('npm run watch');
241246
} catch (\Exception $e) {
242247
$io->error('Failed to start watch mode: ' . $e->getMessage());
248+
// phpcs:ignore MEQP1.Security.DiscouragedFunction -- chdir is necessary to restore original directory
249+
chdir($currentDir);
243250
return false;
244251
}
245252

src/Service/ThemeBuilder/MagentoStandard/Builder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ public function watch(string $themePath, SymfonyStyle $io, OutputInterface $outp
194194
}
195195

196196
try {
197-
passthru('node_modules/.bin/grunt watch');
197+
if ($isVerbose) {
198+
$io->text('Starting watch mode...');
199+
}
200+
$this->shell->execute('node_modules/.bin/grunt watch');
198201
} catch (\Exception $e) {
199202
$io->error('Failed to start watch mode: ' . $e->getMessage());
200203
return false;

src/Service/ThemeBuilder/TailwindCSS/Builder.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,19 @@ public function watch(string $themePath, SymfonyStyle $io, OutputInterface $outp
206206
return false;
207207
}
208208

209+
$currentDir = getcwd();
210+
// phpcs:ignore MEQP1.Security.DiscouragedFunction -- chdir is necessary for npm to run in correct context
211+
chdir($tailwindPath);
212+
209213
try {
210-
// phpcs:ignore MEQP1.Security.DiscouragedFunction -- chdir is necessary for npm to run in correct context
211-
chdir($tailwindPath);
212-
passthru('npm run watch');
214+
if ($isVerbose) {
215+
$io->text('Starting watch mode...');
216+
}
217+
$this->shell->execute('npm run watch');
213218
} catch (\Exception $e) {
214219
$io->error('Failed to start watch mode: ' . $e->getMessage());
220+
// phpcs:ignore MEQP1.Security.DiscouragedFunction -- chdir is necessary to restore original directory
221+
chdir($currentDir);
215222
return false;
216223
}
217224

0 commit comments

Comments
 (0)