Skip to content

Commit

Permalink
Added the no-check option
Browse files Browse the repository at this point in the history
  • Loading branch information
byjg committed Jun 14, 2017
1 parent ff022de commit 6193b5e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
10 changes: 9 additions & 1 deletion src/Console/InstallCommand.php
Expand Up @@ -23,6 +23,13 @@ protected function configure()
'Defines the default service template -- initd or upstart',
'initd'
)
->addOption(
'no-check',
'nc',
InputOption::VALUE_NONE,
'No check for path or file errors. Just install. ',
true
)
->addArgument(
'servicename',
InputArgument::REQUIRED,
Expand Down Expand Up @@ -67,7 +74,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$input->getArgument('rootdir'),
$input->getOption('template'),
$input->getArgument('description'),
$input->getArgument('args')
$input->getArgument('args'),
$input->getOption('no-check')
);
}
}
27 changes: 15 additions & 12 deletions src/Daemonize.php
Expand Up @@ -11,7 +11,8 @@ public static function install(
$curdir,
$template,
$description,
$consoleArgs
$consoleArgs,
$check = true
)
{
$targetPathAvailable = [
Expand All @@ -34,14 +35,14 @@ public static function install(
}

$bootstrap = $curdir . '/' . $bootstrap;
if (!file_exists($bootstrap)) {
if (!file_exists($bootstrap) && $check) {
throw new \Exception("Bootstrap '$bootstrap' not found");
}

$autoload = realpath(__DIR__ . "/../vendor/autoload.php");
if (!file_exists($autoload)) {
$autoload = realpath(__DIR__ . "/../../../autoload.php");
if (!file_exists($autoload)) {
if (!file_exists($autoload) && $check) {
throw new \Exception('Daemonize autoload not found. Did you run `composer dump-autload`?');
}
}
Expand Down Expand Up @@ -77,15 +78,17 @@ public static function install(
$serviceStr = Daemonize::replaceVars($vars, file_get_contents($serviceTemplatePath));

// Check if is OK
require_once ($vars['#BOOTSTRAP#']);
$classParts = explode('::', str_replace("\\\\", "\\", $vars['#CLASS#']));
if (!class_exists($classParts[0])) {
throw new \Exception('Could not find class ' . $classParts[0]);
}
$className = $classParts[0];
$classTest = new $className();
if (!method_exists($classTest, $classParts[1])) {
throw new \Exception('Could not find method ' . $vars['#CLASS#']);
if ($check) {
require_once($vars['#BOOTSTRAP#']);
$classParts = explode('::', str_replace("\\\\", "\\", $vars['#CLASS#']));
if (!class_exists($classParts[0])) {
throw new \Exception('Could not find class ' . $classParts[0]);
}
$className = $classParts[0];
$classTest = new $className();
if (!method_exists($classTest, $classParts[1])) {
throw new \Exception('Could not find method ' . $vars['#CLASS#']);
}
}

set_error_handler(function ($number, $error) {
Expand Down

0 comments on commit 6193b5e

Please sign in to comment.