Commit e9f3b300 authored by Dan Sheppard's avatar Dan Sheppard
Browse files

Pre-commit hook to avoid missing assets.

parent c1b625d9
#! /usr/bin/env perl
use strict;
use warnings;
# Check updated
my $lines = qx(find . -name \*.wasm -printf '%p %T@\n');
my $asset = 0;
my $deploy = 0;
my $other = 0;
my $other_name = '';
foreach my $line (split(/\n/,$lines)) {
my ($filename,$mtime) = split(' ',$line);
if($filename =~ m!/deploy!) {
$deploy = $mtime;
} elsif($filename =~ m!/static/browser!) {
$asset = $mtime;
} elsif($mtime > $other) {
$other = $mtime;
$other_name = $filename;
}
}
if($other > $deploy) {
warn "deploy wasm is older than $other_name. Run deploy.sh!\n";
exit 1;
}
if($other > $asset) {
warn "asset wasm is older than $other_name. Run deploy.sh!\n";
exit 1;
}
# And due to be committed
my $state = qx(git status --porcelain);
foreach my $line (split(/\n/,$state)) {
my ($status,$filename) = split(' ',$line);
if($filename =~ m!/browser\.(wasm|js)$! && $status =~ /.M$/) {
die "$filename not due to be committed!\n";
}
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment