Skip to content

Commit 6dc1bba

Browse files
authored
Merge pull request #135 from universityofadelaide/fix-gitignore
Fix .gitignore insert only require files names/folders
2 parents 08fcbc2 + f05e72e commit 6dc1bba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/actions/GitIgnore.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ public static function tasks(Filesystem $filesystem, string $scaffoldPath, strin
4242
$gitIgnore = file_get_contents($gitIgnorePath);
4343

4444
// Get list of file paths which need to be added to .gitignore.
45-
$requiredPath = $scaffoldPath . '/required';
46-
$fileTasks = ScaffoldFiles::tasks($filesystem, $requiredPath, $projectPath);
45+
$fileTasks = ScaffoldFiles::tasks($filesystem, $scaffoldPath, $projectPath);
46+
47+
// Filter only files from the "required" folder.
48+
$requiredTasks = array_filter(
49+
$fileTasks,
50+
fn (CopyFile $task): bool => str_contains($task->getOrigin(), '/required')
51+
);
4752
$paths = array_filter(
48-
array_map(fn (CopyFile $task) => $task->getFilename(), $fileTasks),
53+
array_map(fn (CopyFile $task) => $task->getFilename(), $requiredTasks),
4954
fn (string $fileName): bool => false === strpos($gitIgnore, $fileName)
5055
);
5156

0 commit comments

Comments
 (0)