Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 64 lines (49 sloc) 1.25 KB
#!/usr/bin/perl
use Cwd;
(my $out, $path, $hubotscriptpath, $jsonpath, $dir);
$dir = cwd;
if(@ARGV > 0){
$path = $ARGV[0];
if($path eq "--help"){
print "usage: ./install <path to hubot> for example \"./install ../hubot\"\n";
exit(0);
}
print $path . "\n";
}else{
my $test = system("cd ../hubot");
if($test == 0){
#$path = "/Users/hagenlauer/Documents/Developement/hubot";
$path = "../hubot";
}else{
die("DAFUQ? no parameters, where am I supposed to write that shit at? try ./install --help");
}
}
print "using path: $path \n";
$jsonpath = $path."/";
$hubotscriptpath = $path . "/node_modules/hubot-scripts/src/scripts";
$out = qx/find . -name '*.coffee'/;
open JSON , ">".$jsonpath."hubot-scripts.json";
print JSON "[";
my @arr = split (/\n/,$out);
my $cnt = 0;
foreach(@arr){
$_ =~ s/\.\///;
#print "rm $hubotscriptpath/$_\n";
#print "ln -s $_ $hubotscriptpath/$_\n";
system("rm $hubotscriptpath/$_"); #delete the old links, that might me deprecated
if($cnt == 0){
print JSON "\"".$_."\",";
$cnt++;
next;
}
if($cnt == $#arr){
print JSON "\"".$_."\"";
$cnt++;
next;
}
print JSON "\"".$_."\",";
$cnt ++;
}
print JSON "]";
#print ("ln -s $dir/*.coffee $hubotscriptpath \n");
system("ln -s $dir/*.coffee $hubotscriptpath");