All files / kanbn/src/controller board.js

93.18% Statements 41/44
91.66% Branches 11/12
100% Functions 1/1
93.18% Lines 41/44

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 451x 1x 1x 1x 1x 15x 15x 15x 1x 1x 1x 14x 14x 14x 14x 14x 15x       14x 15x 1x 1x 1x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 12x 12x 12x 12x 13x 13x 1x 13x 1x  
const kanbn = require('../main');
const utility = require('../utility');
const board = require('../board');
 
module.exports = async args => {
 
  // Make sure kanbn has been initialised
  if (!await kanbn.initialised()) {
    utility.error('Kanbn has not been initialised in this folder\nTry running: {b}kanbn init{b}');
    return;
  }
 
  // Get the index and make sure it has some columns
  let index;
  try {
    index = await kanbn.getIndex();
  } catch (error) {
    utility.error(error);
    return;
  }
  const columnNames = Object.keys(index.columns);
  if (!columnNames.length) {
    utility.error('No columns defined in the index\nTry running {b}kanbn init -c "column name"{b}');
    return;
  }
 
  // Load and hydrate all tracked tasks
  const tasks = (await kanbn.loadAllTrackedTasks(index)).map(
    task => kanbn.hydrateTask(index, task)
  );
 
  // Show the board
  board
  .show(index, tasks, args.view, args.json)
  .then(() => {
    utility.showDateDriftHint(
      kanbn.getDateDrift(index, tasks),
      !args.json && kanbn.isVerbose(index)
    );
  })
  .catch(error => {
    utility.error(error);
  });
};