Documentation section

Conditions

Learn how to introduce even more complex logic for upload/download with conditions.

With conditions, you can introduce complex logic for processing files while they are uploaded / downloaded.

The example below shows different ways how you can use conditions:

{
  // ... other parts omitted for brevity ...
  "upload": {
    "type": "android",
    "files": [
  
      {
        // ...
        "conditions": "!~equals: ${path}, src"
      },

      {
        // ...
        "conditions": [
           "!~equals: ${path}, src",
           [
              "contains: ab, ${path}",
              "contains: cd, ${path}"
           ]   
        ]
      }

    ]
  }
}

Single condition πŸ”—

The simplest way to use a single condition is:

{
  // ...
  "conditions": "!~equals: ${path}, src"
}

Conditions with AND / OR πŸ”—

The full form of conditions is shown below.

{
  // ...
  "conditions": [
    "condition1",
    [
      "condition2.1",
      "condition2.2"
    ],
    [
      "condition3.1",
      "condition3.1"
    ]    
  ]
}

The example above is the same as this formula:

condition1 || (condition2.1 && condition2.2) || (condition3.1 && condition3.2)

Expressions πŸ”—

equals πŸ”—

equals: input, term1, term2, term3

Returns true if the input equals at least one of the terms.

contains πŸ”—

contains: term, text

Returns true if the term is contained in the text.

containsWord πŸ”—

containsWord: term, text

Returns true if the term is contained in the text but only if it’s a whole word. The text is split by the spaces and each of the parts is tested against the term.

It’s useful for checking for the existence of a particular group or product flavor, etc.

empty πŸ”—

empty: text

Returns true if the text is blank (empty or whitespaces only).

startsWith πŸ”—

startsWith: term, text

Returns true if the text starts with the term.

endsWith πŸ”—

endsWith: term, text

Returns true if the text ends with the term.

Variables πŸ”—

Variables can be used as any of the parameters in the expression.

{
  // ...
  "conditions": "equals: ${path}, ${expectedPath}"
}

Negation πŸ”—

Prepend ! before the expression name to negate the output of the command.

Example:

!equals: term1, term2

Returns false if the term1 is equals to term2.

Case-sensitivity πŸ”—

By default, all operations are case-sensitive.

Prepend ~ before the expression name to switch to the case-insensitive mode.

Example:

~equals: term1, TERM2

Returns true if the term1 is equals to the term2. The check is case-insensitive.

Single line AND πŸ”—

If you need a condition with more expressions, you can use | character to join more expressions on a single line.

{
  // ...
  "conditions": "exp1 | exp2 | exp3"
}

The example above is the same as: exp1 && exp2 && exp3

Special characters πŸ”—

Some characters have a special meaning and so it’s necessary to replace them.

  • white-spaces are trimmed to prevent formatting issues, please use %space% instead
  • , is used as parameter separator, please use %comma% instead
  • $ is used for including variables, please use %dollar% instead
  • | is used for separating more command on a single line, please use %vbar% instead

Example:

For checking whether the ${path} is equal to the weird string ab,c (starts with space), please replace special characters like this:

{
  // ...
  "conditions": "equals: ${path}, %space%ab%comma%c"
}