Skip to content

Commit

Permalink
clean up some things.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 17, 2014
1 parent e6d0092 commit 770eb9d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 67 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/vendor
/.vagrant
/var/config.json
10 changes: 5 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ VAGRANTFILE_API_VERSION = "2"
require 'json'
require 'yaml'

homesteadConfig = JSON.parse(File.read("var/config.json"))
homesteadYamlPath = homesteadConfig["directory"] + "/Homestead.yaml"
afterScriptPath = homesteadConfig["directory"] + "/after.sh"
homesteadYamlPath = File.expand_path("~/.homestead/Homestead.yaml")
afterScriptPath = File.expand_path("~/.homestead/after.sh")
aliasesPath = File.expand_path("~/.homestead/aliases")

require_relative 'scripts/homestead.rb'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? homesteadConfig["directory"] + "/aliases" then
config.vm.provision "file", source: homesteadConfig["directory"] + "/aliases", destination: "~/.bash_aliases"
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end

Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
Expand Down
6 changes: 5 additions & 1 deletion homestead
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ else
require __DIR__.'/../../autoload.php';
}

function homestead_path()
{
return $_SERVER['HOME'].'/.homestead';
}

$app = new Symfony\Component\Console\Application('Laravel Homestead', '2.0.0');
$app->add(new Laravel\Homestead\DestroyCommand);
$app->add(new Laravel\Homestead\DirectoryCommand);
$app->add(new Laravel\Homestead\HaltCommand);
$app->add(new Laravel\Homestead\InitCommand);
$app->add(new Laravel\Homestead\ResumeCommand);
Expand Down
47 changes: 0 additions & 47 deletions src/DirectoryCommand.php

This file was deleted.

19 changes: 6 additions & 13 deletions src/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,19 @@ protected function configure()
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$directory = $_SERVER['HOME'].'/.homestead';

if (is_dir($directory))
if (is_dir(homestead_path()))
{
throw new \InvalidArgumentException("Homestead has already been initialized.");
}

mkdir($directory);

copy(__DIR__.'/stubs/Homestead.yaml', $directory.'/Homestead.yaml');
copy(__DIR__.'/stubs/after.sh', $directory.'/after.sh');
copy(__DIR__.'/stubs/aliases', $directory.'/aliases');
mkdir(homestead_path());

file_put_contents(
__DIR__.'/../var/config.json',
json_encode(['directory' => realpath($directory)], JSON_PRETTY_PRINT)
);
copy(__DIR__.'/stubs/Homestead.yaml', homestead_path().'/Homestead.yaml');
copy(__DIR__.'/stubs/after.sh', homestead_path().'/after.sh');
copy(__DIR__.'/stubs/aliases', homestead_path().'/aliases');

$output->writeln('<comment>Creating Homestead.yaml file...</comment> <info>✔</info>');
$output->writeln('<comment>Homestead.yaml file created at:</comment> '.$directory.'/Homestead.yaml');
$output->writeln('<comment>Homestead.yaml file created at:</comment> '.homestead_path().'/Homestead.yaml');
}

}
Empty file removed var/.gitkeep
Empty file.

0 comments on commit 770eb9d

Please sign in to comment.