From a48675005bf048cd3fdb4cbfc8c5d84817099e44 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 13 Jan 2013 15:57:03 +0100 Subject: [PATCH 1/2] Implicitly create composer.json in require command This allows shorteninig install instructions if you do not want to use init (because it is interactive) and you do not want to use create-project (there is no skeleton, or you do not want to use a skeleton). --- src/Composer/Command/RequireCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index f75ec44db..1f3ae7a5a 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -54,8 +54,8 @@ EOT { $file = Factory::getComposerFile(); - if (!file_exists($file)) { - $output->writeln(''.$file.' not found.'); + if (!file_exists($file) && !file_put_contents($file, "{}\n")) { + $output->writeln(''.$file.' could not be created.'); return 1; } From 24611ec9191370c532a75af3788393b391da83d7 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 13 Jan 2013 16:02:50 +0100 Subject: [PATCH 2/2] Add newline because JsonManipulator does not expand {} --- src/Composer/Command/RequireCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 1f3ae7a5a..425481572 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -54,7 +54,7 @@ EOT { $file = Factory::getComposerFile(); - if (!file_exists($file) && !file_put_contents($file, "{}\n")) { + if (!file_exists($file) && !file_put_contents($file, "{\n}\n")) { $output->writeln(''.$file.' could not be created.'); return 1;