const execa = require('execa');
const Listr = require('listr');

const tasks = new Listr([
  {
    title: '🗑  Purge old assets',
    task: () => execa.shell("./tasks/subtasks/cleanAssets.sh")
  },
  {
    title: '🚧  Compile build',
    task: () => {
      return new Listr([
        {
          title: '🐞  Lint all CSS and JS',
          task: () => execa.shell("./tasks/subtasks/lint.sh")
        },
        {
          title: 'Compile JavaScript using Webpack',
          task: () => execa.shell("./tasks/subtasks/scriptsProd.sh")
        },
        {
          title: 'Compile CSS using Node-sass',
          task: () => execa.shell("./tasks/subtasks/stylesProd.sh")
        },
        {
          title: 'Build new spritesheet',
          task: () => execa.shell("./tasks/subtasks/createSprite.sh")
        },
        {
          title: 'Purge current dist/ directory',
          task: () => execa.shell("./tasks/subtasks/cleanDist.sh")
        }
      ], { concurrent: true });
    }
  },
  {
    title: '🚚  Copy all files to dist/',
    task: () => execa.shell('./tasks/subtasks/copyDist.sh')
  },
  {
    title: '📝  Rev assets',
    task: () => {
      return new Listr([
        {
          title: 'Updating sprite version',
          task: () => execa.shell('node ./tasks/subtasks/versionSprite.js')
        },
        {
          title: 'Update CSS and JS versions',
          task: () => execa.shell('node ./tasks/subtasks/versionAssets.js')
        }
      ])
    },
  },
  {
    title: '🏁  Tidy up',
    task: () => {
      return new Listr([
        {
          title: 'Minify production images',
          task: () => execa.shell('node ./tasks/subtasks/minifyImages.js')
        },
        {
          title: 'Remove temporary files/folders',
          task: () => execa.shell('./tasks/subtasks/cleanDistAssets.sh')
        }
      ], { concurrent: true })
    }
  }
]);

tasks.run().catch(err => {
  console.error(err.message);
});

@@ -84,24 +84,126 @@
 Listr(%5B%0A  %7B%0A
+    title: '%F0%9F%90%9E  Lint all CSS and JS',%0A    task: () =%3E execa.shell(%22./tasks/subtasks/lint.sh%22)%0A  %7D,%0A  %7B%0A
     title: '
@@ -384,134 +384,8 @@
   %7B%0A
-          title: '%F0%9F%90%9E  Lint all CSS and JS',%0A          task: () =%3E execa.shell(%22./tasks/subtasks/lint.sh%22)%0A        %7D,%0A        %7B%0A
     

Reorder build process