Skip to content

Commit

Permalink
Merge pull request #7 from ichesnokov/master
Browse files Browse the repository at this point in the history
Get rid of deprecated File::Mkdir usage, use Shell::Command instead
  • Loading branch information
Tadeusz Sośnierz committed May 13, 2011
2 parents d4a8946 + a3aaaa2 commit 6d5f1f5
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 50 deletions.
4 changes: 2 additions & 2 deletions bin/panda
@@ -1,5 +1,5 @@
#!/usr/bin/env perl6 #!/usr/bin/env perl6
use File::Mkdir; use Shell::Command;
use Panda; use Panda;


subset Command of Str where subset Command of Str where
Expand Down Expand Up @@ -79,7 +79,7 @@ if %*ENV<PANDA_DEFAULT_OPTS> {
my $panda; my $panda;
{ {
my $pandadir = %*ENV<HOME> ~ '/.panda'; my $pandadir = %*ENV<HOME> ~ '/.panda';
mkdir $pandadir, :p unless $pandadir.IO ~~ :d; mkpath $pandadir unless $pandadir.IO ~~ :d;


my $projectsfile = "$pandadir/projects.json"; my $projectsfile = "$pandadir/projects.json";
unless $projectsfile.IO ~~ :f { unless $projectsfile.IO ~~ :f {
Expand Down
37 changes: 0 additions & 37 deletions ext/File/Mkdir.pm

This file was deleted.

60 changes: 60 additions & 0 deletions ext/Shell/Command.pm
@@ -0,0 +1,60 @@
module Shell::Command;

sub cat(*@files) is export {
for @files -> $f {
given open($f) {
for .lines -> $line {
say $line;
}
.close
}
}
}

sub eqtime($source, $dest) is export {
???
}

sub rm_f(*@files) is export {
for @files -> $f {
unlink $f if $f.IO ~~ :e;
}
}

sub rm_rf(*@files) is export {
???
}

sub touch(*@files) is export {
???
}

sub mv(*@args) is export {
???
}

sub cp(*@args) is export {
???
}

sub mkpath(*@paths) is export {
for @paths -> $name {
for [\~] $name.split('/').map({"$_/"}) {
mkdir($_) unless .IO.d
}
}
}

sub test_f($file) is export {
???
}

sub test_d($file) is export {
???
}

sub dos2unix($file) is export {
???
}

# vim: ft=perl6
4 changes: 2 additions & 2 deletions lib/Panda/Builder.pm
@@ -1,7 +1,7 @@
use Pies; use Pies;
use Panda::Common; use Panda::Common;
use File::Find; use File::Find;
use File::Mkdir; use Shell::Command;


class Panda::Builder does Pies::Builder { class Panda::Builder does Pies::Builder {
has $!resources; has $!resources;
Expand All @@ -27,7 +27,7 @@ class Panda::Builder does Pies::Builder {
# list of files to compile # list of files to compile
my @files = find(dir => 'lib', name => /\.pm6?$/).list; my @files = find(dir => 'lib', name => /\.pm6?$/).list;
my @dirs = @files.map(*.dir).uniq; my @dirs = @files.map(*.dir).uniq;
mkdir "blib/$_", :p for @dirs; mkpath "blib/$_" for @dirs;


my @tobuild = self.build-order(@files); my @tobuild = self.build-order(@files);
my $p6lib = "{cwd}/blib/lib:{cwd}/lib:{%*ENV<PERL6LIB>}"; my $p6lib = "{cwd}/blib/lib:{cwd}/lib:{%*ENV<PERL6LIB>}";
Expand Down
4 changes: 2 additions & 2 deletions lib/Panda/Common.pm
@@ -1,13 +1,13 @@
module Panda::Common; module Panda::Common;
use File::Mkdir; use Shell::Command;


sub dirname ($mod as Str) is export { sub dirname ($mod as Str) is export {
$mod.subst(':', '_', :g); $mod.subst(':', '_', :g);
} }


sub indir (Str $where, Callable $what) is export { sub indir (Str $where, Callable $what) is export {
my $old = cwd; my $old = cwd;
mkdir $where, :p; mkpath $where;
chdir $where; chdir $where;
my $fail; my $fail;
try { $what(); CATCH { $fail = $! } } try { $what(); CATCH { $fail = $! } }
Expand Down
2 changes: 1 addition & 1 deletion lib/Panda/Ecosystem.pm
@@ -1,6 +1,6 @@
use Pies; use Pies;
use JSON::Tiny; use JSON::Tiny;
use File::Mkdir; use Shell::Command;


class Panda::Ecosystem is Pies::Ecosystem { class Panda::Ecosystem is Pies::Ecosystem {
has $!statefile; has $!statefile;
Expand Down
4 changes: 2 additions & 2 deletions lib/Panda/Fetcher.pm
Expand Up @@ -2,7 +2,7 @@ use Pies;
use Panda::Common; use Panda::Common;
use Panda::Resources; use Panda::Resources;
use File::Find; use File::Find;
use File::Mkdir; use Shell::Command;


class Panda::Fetcher does Pies::Fetcher { class Panda::Fetcher does Pies::Fetcher {
has $!resources; has $!resources;
Expand Down Expand Up @@ -39,7 +39,7 @@ class Panda::Fetcher does Pies::Fetcher {
# that's sort of ugly, I know, but we need # that's sort of ugly, I know, but we need
# <source-url> stripped # <source-url> stripped
my $where = "$dest/{$_.dir.substr($url.chars)}"; my $where = "$dest/{$_.dir.substr($url.chars)}";
mkdir $where, :p; mkpath $where;
next if $_.IO ~~ :d; next if $_.IO ~~ :d;
$_.IO.copy("$where/{$_.name}"); $_.IO.copy("$where/{$_.name}");
} }
Expand Down
8 changes: 4 additions & 4 deletions lib/Panda/Installer.pm
@@ -1,7 +1,7 @@
use Pies; use Pies;
use Panda::Common; use Panda::Common;
use File::Find; use File::Find;
use File::Mkdir; use Shell::Command;


class Panda::Installer does Pies::Installer { class Panda::Installer does Pies::Installer {
has $!resources; has $!resources;
Expand All @@ -17,13 +17,13 @@ class Panda::Installer does Pies::Installer {
if 'blib'.IO ~~ :d { if 'blib'.IO ~~ :d {
for find(dir => 'blib', type => 'file').list -> $i { for find(dir => 'blib', type => 'file').list -> $i {
# .substr(5) to skip 'blib/' # .substr(5) to skip 'blib/'
mkdir "$!destdir/{$i.dir.substr(5)}", :p; mkpath "$!destdir/{$i.dir.substr(5)}";
$i.IO.copy("$!destdir/{$i.Str.substr(5)}"); $i.IO.copy("$!destdir/{$i.Str.substr(5)}");
} }
} }
if 'bin'.IO ~~ :d { if 'bin'.IO ~~ :d {
for find(dir => 'bin', type => 'file').list -> $bin { for find(dir => 'bin', type => 'file').list -> $bin {
mkdir "$!destdir/{$bin.dir}", :p; mkpath "$!destdir/{$bin.dir}";
$bin.IO.copy("$!destdir/$bin"); $bin.IO.copy("$!destdir/$bin");
"$!destdir/$bin".IO.chmod(0o755); "$!destdir/$bin".IO.chmod(0o755);
} }
Expand All @@ -32,7 +32,7 @@ class Panda::Installer does Pies::Installer {
for find(dir => 'doc', type => 'file').list -> $doc { for find(dir => 'doc', type => 'file').list -> $doc {
my $path = "$!destdir/{$p.name.subst(':', '/', :g)}" my $path = "$!destdir/{$p.name.subst(':', '/', :g)}"
~ "/{$doc.dir}"; ~ "/{$doc.dir}";
mkdir $path, :p; mkpath $path;
$doc.IO.copy("$path/{$doc.name}"); $doc.IO.copy("$path/{$doc.name}");
} }
} }
Expand Down

0 comments on commit 6d5f1f5

Please sign in to comment.