Is there a way to get the version from META6.json in Perl6 module code?

前端 未结 1 694
误落风尘
误落风尘 2021-01-18 06:09

I want to do something like this:

die \"Fatal error: application version $MY-APPLICATION-VERSION\"

Since a Perl6 module cannot assume the r

相关标签:
1条回答
  • 2021-01-18 06:48

    As of rakudo v2019.03 modules may access the Distribution object used to load it via $?DISTRIBUTION. This allows the following:

    unit module My::Module;
    
    BEGIN my $VERSION = $?DISTRIBUTION.meta<version>;
    use My::SubModule:ver($VERSION); # ensure we only ever use the version included in this distribution
    
    die "Fatal error: application version $VERSION"
    
    0 讨论(0)
提交回复
热议问题