Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 6ea2077

Browse files
committed
Improved verbosity handling
1 parent 02d70e6 commit 6ea2077

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

src/Command/InstallCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
5959
}
6060

6161
try {
62-
$installer->install($installPath);
62+
$installer->install($installPath, (bool)$input->getOption('verbose'));
6363
} catch (\RuntimeException $e) {
6464
$io->writeError('ERROR: '.$e->getMessage());
6565
// TODO : Use verbosity levels to enable showing the stacktrace
6666
return self::RETURN_CODE_INSTALLER_INSTALL_ERROR;
6767
}
6868

69+
$io->write('<info>The Jupyter-PHP kernel has been successfully installed.</info>');
70+
6971
return self::RETURN_CODE_OK;
7072
}
7173
}

src/Installer/Installer.php

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ public static function getInstaller($composerCmd = null)
4343

4444
/**
4545
* @param null|string $installPath
46+
* @param bool $beVerbose
4647
*/
47-
public function install($installPath = null)
48+
public function install($installPath = null, $beVerbose = false)
4849
{
4950
$installPath = (null !== $installPath) ? $installPath : $this->getInstallPath();
5051
if (null !== $installPath && !$this->system->validatePath($installPath)) {
5152
throw new \RuntimeException('Invalid install path.');
5253
}
5354

5455
$this->system->ensurePath($installPath);
55-
$this->executeComposerCommand($installPath);
56+
$this->executeComposerCommand($installPath, $beVerbose);
5657

5758
$this->installKernel();
5859
}
@@ -69,17 +70,33 @@ protected abstract function installKernel();
6970

7071
/**
7172
* @param string $installPath
73+
* @param bool $beVerbose
7274
*/
73-
protected function executeComposerCommand($installPath)
75+
protected function executeComposerCommand($installPath, $beVerbose = false)
7476
{
7577
$composerStatus = 0;
7678

77-
echo "\n";
78-
passthru(
79-
'PATH='.getenv('PATH').' '.$this->composerCmd.' --working-dir="'.$installPath.'" create-project dawehner/jupyter-php pkgs',
80-
$composerStatus
81-
);
82-
echo "\n";
79+
if ($beVerbose) {
80+
echo "\n";
81+
passthru(
82+
'PATH=' . getenv('PATH') . ' ' .
83+
$this->composerCmd . ' --prefer-dist --no-interaction --working-dir="' .
84+
$installPath .'" create-project litipk/jupyter-php=dev-master pkgs',
85+
86+
$composerStatus
87+
);
88+
echo "\n";
89+
} else {
90+
$composerOutputLines = [];
91+
$composerOutput = exec(
92+
'PATH=' . getenv('PATH') . ' ' .
93+
$this->composerCmd . ' --prefer-dist --no-interaction --no-progress --working-dir="' .
94+
$installPath .'" create-project litipk/jupyter-php=dev-master pkgs > /dev/null 2>&1 ',
95+
96+
$composerOutputLines,
97+
$composerStatus
98+
);
99+
}
83100

84101
if ($composerStatus !== 0) {
85102
throw new \RuntimeException('Error while trying to download Jupyter-PHP dependencies with Composer.');

0 commit comments

Comments
 (0)