A small command-line utility for inspecting the contents of package.json files.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

12345678910111213141516171819202122232425262728293031
  1. const assert = require('assert');
  2. const traversePath = require('./lib').traversePath;
  3. const ESCAPE_CODES = {
  4. RESET_COLOR: '\x1b[0m',
  5. FG_GREEN: '\x1b[32m',
  6. };
  7. const testCases = [
  8. {
  9. expected: 1,
  10. actual: traversePath({ a: 1 }, ['a']),
  11. },
  12. {
  13. expected: 3,
  14. actual: traversePath({ a: { b: { c: 3 } } }, ['a', 'b', 'c']),
  15. },
  16. {
  17. expected: 2,
  18. actual: traversePath({ a: [1, 2, 3] }, ['a', 1]),
  19. },
  20. ];
  21. testCases.forEach((testCase, i) => {
  22. assert.deepEqual(testCase.actual, testCase.expected);
  23. [ESCAPE_CODES.FG_GREEN, '.', ESCAPE_CODES.RESET_COLOR].forEach(el =>
  24. process.stdout.write(el)
  25. );
  26. });
  27. console.log(ESCAPE_CODES.FG_GREEN, 'OK', ESCAPE_CODES.RESET_COLOR);