Permalink
Browse files

Merge pull request #7 from ichesnokov/master

Get rid of deprecated File::Mkdir usage, use Shell::Command instead
  • Loading branch information...
2 parents d4a8946 + a3aaaa2 commit 6d5f1f51cd27bb63f55e0e13ff7ffcbd14e6aa17 @tadzik committed May 13, 2011
Showing with 73 additions and 50 deletions.
  1. +2 −2 bin/panda
  2. +0 −37 ext/File/Mkdir.pm
  3. +60 −0 ext/Shell/Command.pm
  4. +2 −2 lib/Panda/Builder.pm
  5. +2 −2 lib/Panda/Common.pm
  6. +1 −1 lib/Panda/Ecosystem.pm
  7. +2 −2 lib/Panda/Fetcher.pm
  8. +4 −4 lib/Panda/Installer.pm
View
@@ -1,5 +1,5 @@
#!/usr/bin/env perl6
-use File::Mkdir;
+use Shell::Command;
use Panda;
subset Command of Str where
@@ -79,7 +79,7 @@ if %*ENV<PANDA_DEFAULT_OPTS> {
my $panda;
{
my $pandadir = %*ENV<HOME> ~ '/.panda';
- mkdir $pandadir, :p unless $pandadir.IO ~~ :d;
+ mkpath $pandadir unless $pandadir.IO ~~ :d;
my $projectsfile = "$pandadir/projects.json";
unless $projectsfile.IO ~~ :f {
View
@@ -1,37 +0,0 @@
-use v6;
-
-module File::Mkdir;
-
-multi sub mkdir(Str $name, $mode = 0o777, :$p!) is export {
- for [\~] $name.split('/').map({"$_/"}) {
- mkdir($_) unless .IO.d
- }
-}
-
-=begin pod
-
-=head1 NAME
-
-File::Mkdir -- provides recursive mkdir
-
-=head1 SYNOPSIS
-
- use File::Mkdir;
-
- # special mkdir exported in File::Mkdir
- mkdir '/some/directory/tree', :p;
- # just a casual, built-in mkdir
- mkdir 'directory';
-
-=head1 DESCRIPTION
-
-C<File::Mkdir> provides an mkdir variant, which, when provided the :p
-parameter, will create the directory tree recursively. For example,
-calling C<mkdir 'foo/bar', :p> will create the foo directory (unless
-it alredy exists), then the foo/bar directory (unless it exists).
-The standard Perl 6 C<mkdir> is still available, and will be called
-when the :p parameter is not passed.
-
-=end pod
-
-# vim: ft=perl6
View
@@ -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
View
@@ -1,7 +1,7 @@
use Pies;
use Panda::Common;
use File::Find;
-use File::Mkdir;
+use Shell::Command;
class Panda::Builder does Pies::Builder {
has $!resources;
@@ -27,7 +27,7 @@ class Panda::Builder does Pies::Builder {
# list of files to compile
my @files = find(dir => 'lib', name => /\.pm6?$/).list;
my @dirs = @files.map(*.dir).uniq;
- mkdir "blib/$_", :p for @dirs;
+ mkpath "blib/$_" for @dirs;
my @tobuild = self.build-order(@files);
my $p6lib = "{cwd}/blib/lib:{cwd}/lib:{%*ENV<PERL6LIB>}";
View
@@ -1,13 +1,13 @@
module Panda::Common;
-use File::Mkdir;
+use Shell::Command;
sub dirname ($mod as Str) is export {
$mod.subst(':', '_', :g);
}
sub indir (Str $where, Callable $what) is export {
my $old = cwd;
- mkdir $where, :p;
+ mkpath $where;
chdir $where;
my $fail;
try { $what(); CATCH { $fail = $! } }
View
@@ -1,6 +1,6 @@
use Pies;
use JSON::Tiny;
-use File::Mkdir;
+use Shell::Command;
class Panda::Ecosystem is Pies::Ecosystem {
has $!statefile;
View
@@ -2,7 +2,7 @@ use Pies;
use Panda::Common;
use Panda::Resources;
use File::Find;
-use File::Mkdir;
+use Shell::Command;
class Panda::Fetcher does Pies::Fetcher {
has $!resources;
@@ -39,7 +39,7 @@ class Panda::Fetcher does Pies::Fetcher {
# that's sort of ugly, I know, but we need
# <source-url> stripped
my $where = "$dest/{$_.dir.substr($url.chars)}";
- mkdir $where, :p;
+ mkpath $where;
next if $_.IO ~~ :d;
$_.IO.copy("$where/{$_.name}");
}
View
@@ -1,7 +1,7 @@
use Pies;
use Panda::Common;
use File::Find;
-use File::Mkdir;
+use Shell::Command;
class Panda::Installer does Pies::Installer {
has $!resources;
@@ -17,13 +17,13 @@ class Panda::Installer does Pies::Installer {
if 'blib'.IO ~~ :d {
for find(dir => 'blib', type => 'file').list -> $i {
# .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)}");
}
}
if 'bin'.IO ~~ :d {
for find(dir => 'bin', type => 'file').list -> $bin {
- mkdir "$!destdir/{$bin.dir}", :p;
+ mkpath "$!destdir/{$bin.dir}";
$bin.IO.copy("$!destdir/$bin");
"$!destdir/$bin".IO.chmod(0o755);
}
@@ -32,7 +32,7 @@ class Panda::Installer does Pies::Installer {
for find(dir => 'doc', type => 'file').list -> $doc {
my $path = "$!destdir/{$p.name.subst(':', '/', :g)}"
~ "/{$doc.dir}";
- mkdir $path, :p;
+ mkpath $path;
$doc.IO.copy("$path/{$doc.name}");
}
}

0 comments on commit 6d5f1f5

Please sign in to comment.