From 9a2204cd74d3aaac464ab6d636503f512816b1da Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 16 Feb 2012 20:40:57 +0100 Subject: [PATCH] Improve username detection and other minor fixes --- src/Composer/Command/InitCommand.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index ef075f9f7..56eb2e465 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -43,8 +43,8 @@ class InitCommand extends Command } throw new \InvalidArgumentException( - 'Invalid author string. Must be in the format:'. - ' John Smith ' + 'Invalid author string. Must be in the format: '. + 'John Smith ' ); } @@ -150,6 +150,10 @@ EOT $name = basename($cwd); if (isset($git['github.user'])) { $name = $git['github.user'] . '/' . $name; + } elseif (!empty($_SERVER['USERNAME'])) { + $name = $_SERVER['USERNAME'] . '/' . $name; + } elseif (get_current_user()) { + $name = get_current_user() . '/' . $name; } else { // package names must be in the format foo/bar $name = $name . '/' . $name; @@ -158,7 +162,7 @@ EOT $name = $dialog->askAndValidate( $output, - $dialog->getQuestion('Package name', $name), + $dialog->getQuestion('Package name (/)', $name), function ($value) use ($name) { if (null === $value) { return $name; @@ -371,6 +375,6 @@ EOT } } - file_put_contents($ignoreFile, $contents . $vendor); + file_put_contents($ignoreFile, $contents . $vendor. "\n"); } } \ No newline at end of file