77use Laravel \Prompts \SelectPrompt ;
88use Magento \Framework \Console \Cli ;
99use Magento \Framework \Filesystem \Driver \File ;
10+ use Magento \Framework \Shell ;
1011use OpenForgeProject \MageForge \Console \Command \AbstractCommand ;
1112use OpenForgeProject \MageForge \Model \ThemeList ;
1213use OpenForgeProject \MageForge \Model \ThemePath ;
@@ -25,12 +26,14 @@ class TokensCommand extends AbstractCommand
2526 * @param ThemePath $themePath
2627 * @param BuilderPool $builderPool
2728 * @param File $fileDriver
29+ * @param Shell $shell
2830 */
2931 public function __construct (
3032 private readonly ThemeList $ themeList ,
3133 private readonly ThemePath $ themePath ,
3234 private readonly BuilderPool $ builderPool ,
3335 private readonly File $ fileDriver ,
36+ private readonly Shell $ shell ,
3437 ) {
3538 parent ::__construct ();
3639 }
@@ -114,28 +117,15 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
114117 try {
115118 if ($ isVerbose ) {
116119 $ this ->io ->text ('Running npx hyva-tokens... ' );
117- passthru ('npx hyva-tokens ' , $ returnCode );
118- } else {
119- exec ('npx hyva-tokens 2>&1 ' , $ commandOutput , $ returnCode );
120-
121- if ($ returnCode === 0 ) {
122- $ this ->io ->success ('Hyvä design tokens generated successfully. ' );
123- } else {
124- $ this ->io ->error ('Failed to generate Hyvä design tokens. ' );
125- if (!empty ($ commandOutput )) {
126- $ this ->io ->writeln ($ commandOutput );
127- }
128- }
129120 }
130-
121+
122+ $ this ->shell ->execute ('npx hyva-tokens ' );
123+
131124 chdir ($ currentDir );
132125
133- if ($ returnCode !== 0 ) {
134- return Cli::RETURN_FAILURE ;
135- }
136-
126+ $ this ->io ->success ('Hyvä design tokens generated successfully. ' );
127+
137128 if ($ isVerbose ) {
138- $ this ->io ->success ('Hyvä design tokens generated successfully. ' );
139129 $ this ->io ->newLine ();
140130 $ this ->io ->text ('The generated file can be found at: ' );
141131 $ this ->io ->text ($ tailwindPath . '/generated/hyva-tokens.css ' );
0 commit comments