pretty-quick.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env node
  2. 'use strict';
  3. const chalk = require('chalk');
  4. const mri = require('mri');
  5. const prettyQuick = require('..').default;
  6. const args = mri(process.argv.slice(2));
  7. let success = true;
  8. prettyQuick(
  9. process.cwd(),
  10. Object.assign({}, args, {
  11. onFoundSinceRevision: (scm, revision) => {
  12. console.log(
  13. `🔍 Finding changed files since ${chalk.bold(
  14. scm
  15. )} revision ${chalk.bold(revision)}.`
  16. );
  17. },
  18. onFoundChangedFiles: changedFiles => {
  19. console.log(
  20. `🎯 Found ${chalk.bold(changedFiles.length)} changed ${
  21. changedFiles.length === 1 ? 'file' : 'files'
  22. }.`
  23. );
  24. },
  25. onPartiallyStagedFile: file => {
  26. console.log(`✗ Found ${chalk.bold('partially')} staged file ${file}.`);
  27. success = false;
  28. },
  29. onWriteFile: file => {
  30. console.log(`✍️ Fixing up ${chalk.bold(file)}.`);
  31. },
  32. })
  33. );
  34. if (success) {
  35. console.log('✅ Everything is awesome!');
  36. } else {
  37. console.log(
  38. '✗ Partially staged files were fixed up.' +
  39. ` ${chalk.bold('Please update stage before committing')}.`
  40. );
  41. process.exit(1); // ensure git hooks abort
  42. }