-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.pl
executable file
·45 lines (41 loc) · 1.15 KB
/
build.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl
use 5.30.0;
use warnings;
use File::Path qw/make_path remove_tree/;
use File::Copy::Recursive qw/dircopy/;
use File::Slurper qw/write_text/;
my @sites = (
{ id => 'gurka', title => '🥒 gurka.se' },
{ id => 'persimon', title => 'persimon.se' },
{ id => 'champinjon', title => 'champinjon.se' },
{ id => 'potatis', title => 'potat.is' },
);
# clean build dir
if ( -d 'build' ) {
remove_tree( 'build' ) or die "could not remove build dir: $!";
}
make_path('build') or die "could not create build dir: $!";
# build each site
for my $site ( @sites ) {
my $out_dir = 'build/' . $site->{id} . '/';
make_path($out_dir) or die "could not create site build dir: $!";
dircopy( 'src/common', $out_dir ) or die "copy failed: $!";
if ( -d 'src/'.$site->{id} ) {
dircopy( 'src/'.$site->{id}, $out_dir ) or die "copy failed: $!";
}
# plant site config
write_site_config( $site, $out_dir . 'config.php' );
}
sub write_site_config {
my ( $site, $config_path ) = @_;
my $config_contents = <<CONFIG;
<?
\$config = array(
"id" => "$site->{id}",
"title" => "$site->{title}"
);
return \$config;
?>
CONFIG
write_text( $config_path, $config_contents );
}