Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added an option to install from a git url, bugfix when updating the d…

…atabase, fetch projects.json from a feather service. Next time I'm commiting one thing at a time, promise
  • Loading branch information...
commit bfad4d9cf11a05c457635a353ebea5d72ccd5b5d 1 parent 427f91b
@tadzik authored
Showing with 23 additions and 28 deletions.
  1. +23 −28 bin/neutro
View
51 bin/neutro
@@ -63,9 +63,9 @@ package Ecosystem {
our $installed = "{$Settings::configdir}/installed";
our %modules;
- our sub init {
+ our sub init(Bool $update) {
Settings::init();
- unless "{$Settings::configdir}/projects.json".IO ~~ :f {
+ if $update or "{$Settings::configdir}/projects.json".IO !~~ :f {
updatedb;
}
# the database of installed modules
@@ -73,7 +73,9 @@ package Ecosystem {
open($installed, :w).close;
}
+ #note "{time}: parsing json";
my $list = from-json(slurp "{$Settings::configdir}/projects.json");
+ #note "{time}: parsed";
for $list.list -> $mod {
%modules{$mod<name>} = $mod;
}
@@ -156,28 +158,7 @@ package Ecosystem {
notice 'Updating modules database';
indir $Settings::configdir, {
unlink 'projects.json' if 'projects.json'.IO ~~ :e;
- fetch 'ecosystem', 'git://github.com/tadzik/ecosystem.git';
- indir "{$Settings::srcdir}/ecosystem", {
- my @list;
-
- my $fh = open('META.list');
- for $fh.lines -> $url {
- run "wget -q --no-check-certificate $url"
- and die "Failed fetching $url";
- my $info = from-json(slurp('META.info'));
- @list.push($info);
- unlink 'META.info';
- }
-
- given open('projects.json', :w) {
- .say(to-json @list);
- .close;
- }
-
- $fh.close;
- };
- cp "{$Settings::srcdir}/ecosystem/projects.json",
- "{$Settings::configdir}/projects.json";
+ run 'wget --quiet http://feather.perl6.nl:3000/list -O projects.json';
};
}
}
@@ -203,6 +184,15 @@ sub install (Str $module is rw) {
$path = $module;
$meta = from-json slurp "$module/META.info";
$module = $meta<name>;
+ } elsif $module ~~ /\.git$/ {
+ try {
+ $path = Ecosystem::fetch $module, $module;
+ $meta = from-json slurp "$path/META.info";
+ $module = $meta<name>;
+ CATCH {
+ crap $!;
+ }
+ }
} else {
crap "Module $module not in the ecosystem "
~ "(or no module files in directory $module)";
@@ -272,20 +262,22 @@ sub MAIN (Bool :$v = False,
Bool :$update = False,
Bool :$info = False,
*@args) {
- Ecosystem::init();
+ $help && USAGE();
+
+ Ecosystem::init($update);
$Settings::verbose = $v;
$Settings::notest = $notest;
$Settings::nodeps = $nodeps;
- $help && USAGE();
- $update && Ecosystem::updatedb();
$list && Ecosystem::listmodules();
$listinst && Ecosystem::listinstalled();
$info && Ecosystem::info(@args);
@args».&install unless $info;
- if none(+@args, $info, $listinst, $list, $update) { say "Nothing to do" }
+ if none(+@args, $info, $listinst, $list, $update) {
+ say "Nothing to do"
+ }
}
sub USAGE {
@@ -311,6 +303,9 @@ Examples:
# as above, but from the path ./foo/bar
neutro ./foo/bar
+ # install from a git repo
+ neutro git://github.com/tadzik/perl6-Acme-Meow.git
+
# update the module database and show the list of available modules
neutro --update --list
Please sign in to comment.
Something went wrong with that request. Please try again.