Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Define make-default-ecosystem in Panda::App

Enable Panda::App to be used by other tools to set up the same
ecosystem that bin/panda uses.
  • Loading branch information...
commit da6558d3f24d0239091ffbc62ab45a1fd5899378 1 parent abafd49
Tim Smith softmoth authored
Showing with 34 additions and 34 deletions.
  1. +1 −34 bin/panda
  2. +33 −0 lib/Panda/App.pm
35 bin/panda
View
@@ -8,40 +8,7 @@ use Panda::App;
if %*ENV<PANDA_DEFAULT_OPTS> {
@*ARGS = %*ENV<PANDA_DEFAULT_OPTS> ~ (@*ARGS ?? ' ' ~ @*ARGS !! '');
}
-
-# initialize the Panda object
-my $panda;
-{
- my $pandadir;
- my $destdir = %*ENV<DESTDIR>;
- $destdir = "{cwd}/$destdir" if defined($destdir) && $*OS ne 'MSWin32' && $destdir !~~ /^ '/' /;
- for grep(*.defined, $destdir, %*CUSTOM_LIB<site home>) -> $prefix {
- $destdir = $prefix;
- $pandadir = "$prefix/panda";
- try mkpath $pandadir unless $pandadir.IO ~~ :d;
- last if $pandadir.path.w
- }
- unless $pandadir.path.w {
- die "Found no writable directory into which panda could be installed";
- }
-
- my @extra-statefiles;
- unless $destdir eq %*CUSTOM_LIB<site> {
- for grep(*.defined, $destdir, %*CUSTOM_LIB<site home>) -> $prefix {
- unless $destdir eq $prefix {
- @extra-statefiles.push("$prefix/panda/state");
- }
- }
- }
-
- my $ecosystem = Panda::Ecosystem.new(
- statefile => "$pandadir/state",
- projectsfile => "$pandadir/projects.json",
- extra-statefiles => @extra-statefiles
- );
-
- $panda = Panda.new(:$ecosystem);
-}
+my $panda = Panda.new(:ecosystem(make-default-ecosystem));
# allow switches after positionals
@*ARGS = @*ARGS.grep(/^ '-'/), @*ARGS.grep(/^ <-[-]>/);
33 lib/Panda/App.pm
View
@@ -1,6 +1,39 @@
module Panda::App;
+use Shell::Command;
+use Panda::Ecosystem;
use Panda::Project;
+# initialize the Panda object
+sub make-default-ecosystem is export {
+ my $pandadir;
+ my $destdir = %*ENV<DESTDIR>;
+ $destdir = "{cwd}/$destdir" if defined($destdir) && $*OS ne 'MSWin32' && $destdir !~~ /^ '/' /;
+ for grep(*.defined, $destdir, %*CUSTOM_LIB<site home>) -> $prefix {
+ $destdir = $prefix;
+ $pandadir = "$prefix/panda";
+ try mkpath $pandadir unless $pandadir.IO ~~ :d;
+ last if $pandadir.path.w
+ }
+ unless $pandadir.path.w {
+ die "Found no writable directory into which panda could be installed";
+ }
+
+ my @extra-statefiles;
+ unless $destdir eq %*CUSTOM_LIB<site> {
+ for grep(*.defined, $destdir, %*CUSTOM_LIB<site home>) -> $prefix {
+ unless $destdir eq $prefix {
+ @extra-statefiles.push("$prefix/panda/state");
+ }
+ }
+ }
+
+ return Panda::Ecosystem.new(
+ statefile => "$pandadir/state",
+ projectsfile => "$pandadir/projects.json",
+ extra-statefiles => @extra-statefiles
+ );
+}
+
sub listprojects($panda, :$installed, :$verbose) is export {
my $es = $panda.ecosystem;
my @projects = $es.project-list.sort.map: { $es.get-project($_) };
Please sign in to comment.
Something went wrong with that request. Please try again.