From bacf18ae8cea6fb192cfdf7584c77bd1908bf247 Mon Sep 17 00:00:00 2001 From: Andrew Roslik Date: Thu, 19 Feb 2015 15:45:59 +0200 Subject: [PATCH] - Removed redundant the wildcard for directories. - Added using full path to modman file on generate it. - Added showing an error when the file cannot be generated. - Removed `instructions` files from exclude list. - Added particular composer.* files to exclude list. --- modman-generate | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modman-generate b/modman-generate index ed53f1a..ecd6ca6 100644 --- a/modman-generate +++ b/modman-generate @@ -3,8 +3,8 @@ echo "Simple Modman Generator v0.1.1" . PHP_EOL; $ignoreFiles = array( 'modman', - 'composer', - 'instructions', + 'composer\.json', + 'composer\.lock', '\.gitignore', 'README\.md', 'LICENSE', @@ -19,7 +19,7 @@ preg_match_all( ); $list = array_unique($matches[0]); if (!$list) { - echo "No files found under GIT to place into 'modman' file." . PHP_EOL; + echo "error: No files found under GIT to place into 'modman' file." . PHP_EOL; return; } @@ -30,15 +30,22 @@ $maxLength = max(array_map('strlen', $list)); foreach ($list as $item) { if (is_file($item)) { $space = str_repeat(' ', $maxLength - strlen($item) + 3); - $output[] = "$item $space $item"; } else { $item = rtrim($item, '/') . '/'; $space = str_repeat(' ', $maxLength - strlen($item) + 2); - $output[] = "$item* $space $item"; } + $output[] = "$item $space $item"; } $output = implode("\n", $output); -file_put_contents('modman', $output); -echo "'modman' file generated." . PHP_EOL; +//get GIT root path +$gitRoot = `git rev-parse --show-toplevel`; +//make absolute path to modman file +$file = $gitRoot . DIRECTORY_SEPARATOR . 'modman'; + +if (false === file_put_contents($file, $output)) { + echo "error: 'modman' cannot be generated." . PHP_EOL; +} else { + echo "'modman' file generated." . PHP_EOL; +}