Skip to content

Commit

Permalink
Mite::Shim shouldn't check .mite.pm file exists before trying to requ…
Browse files Browse the repository at this point in the history
…ire it because it breaks FatPacker (issue #34); also minor stylistic changes to Mite::Shim and improvements to 00start.t.
  • Loading branch information
tobyink committed Dec 12, 2022
1 parent 3924ee2 commit 714c9d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 14 additions & 16 deletions lib/Mite/Shim.pm
Expand Up @@ -96,33 +96,31 @@ sub _is_compiling {

sub import {
my $me = shift;
my %arg = map { lc($_) => true } @_;
my %arg = map +( lc($_) => true ), @_;
my ( $caller, $file ) = caller;

if( _is_compiling() ) {
require Mite::Project;
Mite::Project->default->inject_mite_functions(
package => $caller,
file => $file,
arg => \%arg,
shim => $me,
'Mite::Project'->default->inject_mite_functions(
'package' => $caller,
'file' => $file,
'arg' => \%arg,
'shim' => $me,
);
}
else {
# Changes to this filename must be coordinated with Mite::Compiled
my $mite_file = $file . ".mite.pm";
if( !-e $mite_file ) {
croak "Compiled Mite file ($mite_file) for $file is missing";
}

{
local @INC = ('.', @INC);
require $mite_file;
my $mite_file = $file . '.mite.pm';
local @INC = ( '.', @INC );
local $@;
if ( not eval { require $mite_file; 1 } ) {
my $e = $@;
croak "Compiled Mite file ($mite_file) for $file is missing or an error occurred loading it: $e";
}
}

warnings->import;
strict->import;
'warnings'->import;
'strict'->import;
'namespace::autoclean'->import( -cleanee => $caller )
if _HAS_AUTOCLEAN && !$arg{'-unclean'};
}
Expand Down
4 changes: 3 additions & 1 deletion t/00start.t
Expand Up @@ -15,8 +15,10 @@ my %modules = (
Module::Pluggable 5.2
Import::Into 0
Path::Tiny 0.052
Regexp::Util 0.004
Sub::HandlesVia 0.045
Types::Path::Tiny 0
Types::Standard 1.016000
Types::Standard 2.000000
YAML::XS 0.41
Class::XSAccessor 1.19
) },
Expand Down

0 comments on commit 714c9d3

Please sign in to comment.