diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2010-02-27 16:26:13 -0500 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2010-02-27 16:26:18 -0500 |
commit | a12c386c86d000971125d70bf22213fd9595ed45 (patch) | |
tree | f0fe7e4d5f694d58ed70633c1f15c905334d8eb5 /IkiWiki/Setup | |
parent | 4b1da14612c26981055dd186deacc004f93bdad0 (diff) |
Add force_overwrite setting to make setup automator overwrite existing files/directories.
This can be useful if you're driving the setup automator from another
program.
Diffstat (limited to 'IkiWiki/Setup')
-rw-r--r-- | IkiWiki/Setup/Automator.pm | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 9fee4dcb7..79a610e20 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -40,17 +40,19 @@ sub import (@) { my $this=shift; IkiWiki::Setup::merge({@_}); - # Avoid overwriting any existing files. - foreach my $key (qw{srcdir destdir repository dumpsetup}) { - next unless exists $config{$key}; - my $add=""; - my $dir=IkiWiki::dirname($config{$key})."/"; - my $base=IkiWiki::basename($config{$key}); - while (-e $dir.$add.$base) { - $add=1 if ! $add; - $add++; + if (! $config{force_overwrite}) { + # Avoid overwriting any existing files. + foreach my $key (qw{srcdir destdir repository dumpsetup}) { + next unless exists $config{$key}; + my $add=""; + my $dir=IkiWiki::dirname($config{$key})."/"; + my $base=IkiWiki::basename($config{$key}); + while (-e $dir.$add.$base) { + $add=1 if ! $add; + $add++; + } + $config{$key}=$dir.$add.$base; } - $config{$key}=$dir.$add.$base; } # Set up wrapper |