Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix 72] generator config is not case-sensitive consistent #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions bin/lib/Logos/Generator.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package Logos::Generator;
use strict;
use File::Basename;
use Logos::Generator::Thunk;
use Scalar::Util qw(blessed);
use List::Util qw(any);
use Module::Load::Conditional qw(can_load);
$Module::Load::Conditional::VERBOSE = 1;
our $GeneratorPackage = "";
Expand Down Expand Up @@ -40,9 +42,20 @@ sub use {
unshift @INC, $2;
}
$GeneratorPackage = "Logos::Generator::".$generatorName;
::fileError(-1, "I can't find the $generatorName Generator!") if(!can_load(modules => {
$GeneratorPackage."::Generator" => undef
}));
::fileError(-1, "I can't find the '$generatorName' Generator!") if (!can_load(modules => {
$GeneratorPackage . "::Generator" => undef
}));

# Guard against case insensitive filesystems finding the module but not being able to load it
my @availableGeneratorPaths = glob(dirname(__FILE__) . "/Generator/*");
my @availableGenerators = map {basename($_)} @availableGeneratorPaths;
my $generatorDirectoryExists = any {$_ eq $generatorName} @availableGenerators;

if ($generatorDirectoryExists != 1) {
my %generatorNames = map {lc($_) => $_} @availableGenerators;
my $possibleGeneratorName = $generatorNames{lc($generatorName)};
::fileError(-1, "I can't find the '$generatorName' Generator, did you mean '$possibleGeneratorName'?");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For case-sensitive OS support:

  • Move this new code block above the existing $GeneratorPackage block and fall back to the existing fileError if we have no name suggestion.
Suggested change
::fileError(-1, "I can't find the '$generatorName' Generator, did you mean '$possibleGeneratorName'?");
if ($possibleGeneratorName) {
::fileError(-1, "I can't find the '$generatorName' Generator, did you mean '$possibleGeneratorName'?");
}

}
}

1;