Example #1
0
  const handleAssertFailure = assert => {
    const name = assert.name;
    const diag = assert.diag;
    const writeDiff = ({ value, added, removed }) => {
      let style = chalk.white;

      if (added)   style = chalk.green.inverse;
      if (removed) style = chalk.red.inverse;

      return style(value);
    };

    println(`${chalk.red(FIG_CROSS)}  ${chalk.red(name)} at ${chalk.magenta(diag.at)}`, 2);

    if (typeof diag.expected === 'object' && diag.expected !== null) {
      const compared = diffJson(diag.actual, diag.expected)
        .map(writeDiff)
        .join('');

      println(compared, 4);
    } else if (diag.expected === 'undefined' && diag.actual === 'undefined') {
      ;
    } else if (typeof diag.expected === 'string') {
      const compared = diffWords(diag.actual, diag.expected)
        .map(writeDiff)
        .join('');

      println(compared, 4);
    } else {
      println(
        chalk.red.inverse(diag.actual) + chalk.green.inverse(diag.expected),
        4
      );
    }
  };
Example #2
0
    matches.slice(1).forEach(function(match) {
      index += highlighted.slice(index).search(utils.escapeRegExp(match));

      highlighted = highlighted.slice(0, index) + chalk.red.inverse(match) +
          highlighted.slice(index + match.length);

      index += match.length;
    });
Example #3
0
const removeNote = (title) => {
    const notes = loadNotes();
    const notesToKeep = notes.filter(note => note.title !== title)

    if (notes.length > notesToKeep.length) {
        saveNotes(notesToKeep);
        console.log(chalk.green.inverse('Note Removed.'))
    } else {
        console.log(chalk.red.inverse('No Note Found.'))
    }

}
Example #4
0
const removeNote = function (title) {
    const notes = loadNotes()
    const notesToKeep = notes.filter(function (note) {
        return note.title !== title
    })

    if (notes.length > notesToKeep.length) {
        console.log(chalk.green.inverse('Note removed!'))
        saveNotes(notesToKeep)
    } else {
        console.log(chalk.red.inverse('No note found!'))
    }    
}
Example #5
0
const addNote = (title, body) => {
    const notes = loadNotes();
    const duplicateNote = notes.find(note => note.title === title);

    if (!duplicateNote) {
        notes.push({title, body});
        saveNotes(notes);
        console.log(chalk.green.inverse('New note added.'))
    } else {
        console.log(chalk.red.inverse('Note title taken.'))
    }


}
Example #6
0
async.waterfall(tasks, function (aErr, aResults) {
  if (aErr) {
    console.error(
      chalk.red.inverse('Project dependency error!\n\n'),
      'Code ' + aErr.code + '\n',
      aErr.message
    );
    return;
  }

  aResults.push(chalk.cyan('Completed checking project dependencies'));

  console.log(aResults.join('\n'));
});
Example #7
0
const addNote = function (title, body) {
    const notes = loadNotes()
    const duplicateNotes = notes.filter(function (note) {
        return note.title === title
    })

    if (duplicateNotes.length === 0) {
        notes.push({
            title: title,
            body: body
        })
        saveNotes(notes)
        console.log(chalk.green.inverse('New note added!'))
    } else {
        console.log(chalk.red.inverse('Note title taken!'))
    }
}