Skip to content

Instantly share code, notes, and snippets.

@uasi
Created June 10, 2010 17:02
Show Gist options
  • Save uasi/433298 to your computer and use it in GitHub Desktop.
Save uasi/433298 to your computer and use it in GitHub Desktop.
diff --git a/ufo b/ufo
index bcdf016..5c0c51f 100755
--- a/ufo
+++ b/ufo
@@ -1,5 +1,7 @@
#!/usr/bin/env perl6
+#use OSUtilsOrSomething;
+
my $binary = 'perl6';
if @*ARGS == 1 && @*ARGS[0] eq '--alpha' {
$binary = 'alpha';
@@ -10,7 +12,7 @@ elsif @*ARGS {
exit 1;
}
-my $cwd = qx[pwd].chomp;
+my $cwd = cwd();
if 'lib' !~~ :e {
note "lib/ doesn't exist. Nothing to do.";
@@ -21,12 +23,22 @@ elsif 'lib' !~~ :d {
exit 1;
}
-my @module-files = grep { $_ },
- split "\n",
- qx[find lib -name \*.pm -or -name \*.pm6];
+sub find-module-files($dir) {
+ gather for readdir($dir) -> $entry {
+ next if $entry ~~ /^\.\.?$/;
+ my $path = "$dir/$entry";
+ if $path ~~ :d {
+ take find-module-files($path).list;
+ }
+ else {
+ take $path if $path ~~ /\.pm6?$/;
+ }
+ }
+}
+
+my @module-files = find-module-files('lib');
-if !@module-files
- || @module-files.elems == 1 && @module-files[0] ~~ /'no such file'/ {
+if !@module-files {
note "Found no modules in lib/. Nothing to do.";
exit 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment