Skip to content

Commit

Permalink
Merge pull request #36 from alleyinteractive/bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher authored Feb 14, 2023
2 parents afbd952 + ce9e380 commit 684a759
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/mantle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if ( file_exists( __DIR__ . '/../../../autoload.php' ) ) {
require __DIR__ . '/../vendor/autoload.php';
}

$app = new Symfony\Component\Console\Application( 'Mantle Installer', '1.0.2' );
$app = new Symfony\Component\Console\Application( 'Mantle Installer', '1.0.3' );
$app->add( new Mantle\Installer\Console\Install_Command() );

$app->run();
34 changes: 17 additions & 17 deletions src/class-install-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,13 @@ protected function get_wordpress_root( InputInterface $input, OutputInterface $o
$abspath = $name && '.' !== $name ? $cwd . '/' . $name : $cwd;

// Check if 'wp-content' is in the current path.
if ( false !== strpos( '/wp-content/', $abspath ) ) {
$abspath = preg_replace( '#/wp-content/.*$#', '/wp-config.php', $abspath );
$output->writeln( "Using [<fg=yellow>{$abspath}</fg=yellow>] as the WordPress installation." );
return $abspath;
}
if ( false !== strpos( $abspath, '/wp-content/' ) ) {
$abspath = rtrim( preg_replace( '#/wp-content/.*$#', '/', $abspath ), '/' );

// Check if a root-level file exists.
if ( file_exists( $abspath . '/wp-settings.php' ) ) {
$output->writeln( "Using [<fg=yellow>{$abspath}</fg=yellow>] as the WordPress installation." );
return $abspath;
if ( is_dir( $abspath ) && file_exists( $abspath . '/wp-settings.php' ) ) {
$output->writeln( "Using [<fg=yellow>{$abspath}</fg=yellow>] as the WordPress installation." );
return $abspath;
}
}

// Check if we are inside of the default Homestead WordPress environement.
Expand All @@ -115,13 +112,11 @@ protected function get_wordpress_root( InputInterface $input, OutputInterface $o
return null;
}

if ( $input->getOption( 'install' ) ) {
$this->install_wordpress( $abspath, $input, $output );
return $abspath;
}

// Ask the user if we should be installing.
if ( $style->confirm( "Would you like to install WordPress at [<fg=yellow>{$abspath}</fg=yellow>]", true ) ) {
// Ask the user if we should be installing if not already specified.
if (
$input->getOption( 'install' )
|| $style->confirm( "Would you like to install WordPress at [<fg=yellow>{$abspath}</fg=yellow>]", true )
) {
$this->install_wordpress( $abspath, $input, $output );
return $abspath;
}
Expand Down Expand Up @@ -270,6 +265,11 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt
throw new RuntimeException( "Mantle is already installed: [{$mantle_dir}]" );
}

// Check if the directory is empty.
if ( is_dir( $mantle_dir ) && count( scandir( $mantle_dir ) ) > 2 ) {
throw new RuntimeException( "Directory is not empty: [{$mantle_dir}]" );
}

$composer = $this->find_composer();
$commands = [
$composer . " create-project alleyinteractive/mantle {$mantle_dir} --remove-vcs --stability=dev --no-interaction --no-scripts",
Expand Down Expand Up @@ -368,7 +368,7 @@ protected function get_mu_plugin_loader( string $plugin_name ): string {
protected function check_if_hiring(): bool {
try {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://careers.alley.co/wp-json/wp/v2/job/' );
curl_setopt( $ch, CURLOPT_URL, 'https://careers.alley.com/wp-json/wp/v2/job/' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 3 );

Expand Down

0 comments on commit 684a759

Please sign in to comment.