summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/arara/rules/arara-rule-clean.yaml
blob: c1057c558cbad9a823f6502e8d41bab968880735 (plain)
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
46
47
48
49
50
!config
# Arara, the cool TeX automation tool
# Copyright (c) 2021, Island of TeX
# All rights reserved.
#
# This rule is part of arara.
identifier: clean
name: Clean
authors:
- Island of TeX
commands:
- name: Cleaning feature
  command: >
    @{
        prefix = [];
        if (isUnix()) {
            prefix = [ 'rm', '-f' ];
        }
        else {
            prefix = [ 'cmd', '/c', 'del' ];
        }
        if (extensions.isEmpty()) {
            if (getOriginalReference() == reference) {
                throwError('I cannot remove the main file reference.');
            }
            return getCommand(prefix, reference);
        }
        else {
            base = getBasename(reference);
            removals = [];
            foreach(extension : extensions) {
                if (base.concat('.').concat(extension) == getOriginalFile()) {
                    throwError('I cannot remove the main file reference.');
                }
                removals.add(getCommand(prefix, base.concat('.').concat(extension)));
            }
            return removals;
        }
    }
arguments:
- identifier: extensions
  flag: >
    @{
        if (isList(parameters.extensions)) {
            return parameters.extensions;
        }
        else {
            throwError('I was expecting a list of extensions.');
        }
    }