mirror of https://gitee.com/openkylin/mathjax.git
53 lines
1.3 KiB
Perl
Executable File
53 lines
1.3 KiB
Perl
Executable File
#! /usr/bin/perl
|
|
|
|
#
|
|
# Create all the combined configuration files
|
|
#
|
|
# Usage: ./combineMJ [--force] [proj-dir]
|
|
#
|
|
|
|
use Cwd;
|
|
use FindBin;
|
|
|
|
if ($ARGV[0] eq '--force') {$force = true; shift}
|
|
|
|
$DIR = $FindBin::Bin;
|
|
$MJX = shift || getcwd;
|
|
$COMBINELIST = "$DIR/combineMJlist";
|
|
$COMBINELISTU = "$DIR/combineMJlist-unpacked";
|
|
|
|
die "Project directory must contain a config directory\n" unless -d "$MJX/config";
|
|
|
|
|
|
opendir(LISTS,"$DIR/lists") || die "Can't list $DIR/lists: $!\n";
|
|
@lists = grep {/.*\.lis/} readdir(LISTS);
|
|
closedir(LISTS);
|
|
|
|
foreach $list (@lists) {
|
|
$file = $list; $file =~ s/\.[^.]*/.js/;
|
|
$needsUpdate = 1;
|
|
if (-e "$MJX/config/$file" && !$force) {
|
|
$needsUpdate = 0;
|
|
$date = (stat("$MJX/config/$file"))[9];
|
|
open(LIST,"<","$DIR/lists/$list") || warn "Can't read $DIR/lists/$list: $!\n";
|
|
@files = <LIST>; chomp(@files);
|
|
close(LIST);
|
|
foreach $name (@files) {
|
|
last unless $name =~ m/\S/;
|
|
if (!(-e "$MJX/$name") || (stat("$MJX/$name"))[9] > $date) {
|
|
$needsUpdate = 1;
|
|
last;
|
|
}
|
|
}
|
|
}
|
|
if ($needsUpdate) {
|
|
print "Refreshing: config/$file\n";
|
|
system("$COMBINELIST '$MJX' '$DIR/lists/$list' > /dev/null");
|
|
system("$COMBINELISTU '$MJX' '$DIR/lists/$list' > /dev/null");
|
|
} else {
|
|
print "Up to date: config/$file\n";
|
|
}
|
|
}
|
|
|
|
1;
|