function clean (tmpPath, preserve) {

  /**
   * If preserve is a normal integer over 0 thats how many results to keep.
   * If string 'all' then keep all
   * Else: don't preserve anything
   */
  if (preserve === 'all') {

    /**
     * Preserve all artifacts
     * Don't purge any artifacts
     *
     * BEWARE: this can fill the disk up over time
     */
    return;

  } else if (isNormalNonZeroInteger(preserve)) {

    /**
     * Preserve a specific number of artifacts
     *
     * 1 = keep only th last run
     * 2 = keep the last run and the one before it, purging any that happened beforehand
     */

    // Set the path
    let artifactsBasePath = path.resolve(tmpPath + '/../artifacts');

    // The the files in this path
    let artifactFolders = fs.readdirSync(artifactsBasePath);

    // Reverse chronologially sort the files
    artifactFolders.sort(function (a, b) {
      return fs.statSync(path.resolve(artifactsBasePath, b)).mtime.getTime() - fs.statSync(path.resolve(artifactsBasePath, a)).mtime.getTime();
    });

    // Keep only the number of files defined in the config setting 'preserve'.
    keep(artifactsBasePath, artifactFolders, preserve);
  }

  // Always purge tmp, it needs to be empty for next run
  cleanPath(tmpPath);
}
Cleans up the artifacts folder

Generally called in after()