summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/arara/rules/clean.yaml
blob: 1a39ed3f27a7cfe4588c7db241d693d431f96ea5 (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
51
!config
# Arara, the cool TeX automation tool
# Copyright (c) 2018, Paulo Roberto Massa Cereda 
# All rights reserved.
#
# This rule is part of arara.
identifier: clean
name: Clean
authors:
- Marco Daniel
- Paulo Cereda
commands:
- name: Cleaning feature
  command: >
    @{
        prefix = [];
        if (isUnix()) {
            prefix = [ 'rm', '-f' ];
        }
        else {
            prefix = [ 'cmd', '/c', 'del' ];
        }
        if (extensions == '') {
            if (getOriginalFile() == file) {
                throwError('I cannot remove the main file reference.');
            }
            return getCommand(prefix, file);
        }
        else {
            base = getBasename(file);
            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.');
        }
    }