362311792f4d9b44813babc30d2fe90cbf5547bd71ceaeda9bac7d0b19f51f494e078ea807dc6f590d1336c4b2cae2a51c15ff0d6fe73665aec88a1e2baa22 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 'use strict'
  2. const chalk = require('chalk')
  3. const { error, info, warning } = require('log-symbols')
  4. const NOT_GIT_REPO = chalk.redBright(`${error} Current directory is not a git directory!`)
  5. const FAILED_GET_STAGED_FILES = chalk.redBright(`${error} Failed to get staged files!`)
  6. const NO_STAGED_FILES = `${info} No staged files found.`
  7. const NO_TASKS = `${info} No staged files match any configured task.`
  8. const skippingBackup = (hasInitialCommit) => {
  9. const reason = hasInitialCommit ? '`--no-stash` was used' : 'there’s no initial commit yet'
  10. return `${warning} ${chalk.yellow(`Skipping backup because ${reason}.\n`)}`
  11. }
  12. const DEPRECATED_GIT_ADD = `${warning} ${chalk.yellow(
  13. `Some of your tasks use \`git add\` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.`
  14. )}
  15. `
  16. const TASK_ERROR = 'Skipped because of errors from tasks.'
  17. const SKIPPED_GIT_ERROR = 'Skipped because of previous git error.'
  18. const GIT_ERROR = `\n ${error} ${chalk.red(`lint-staged failed due to a git error.`)}`
  19. const PREVENTED_EMPTY_COMMIT = `
  20. ${warning} ${chalk.yellow(`lint-staged prevented an empty git commit.
  21. Use the --allow-empty option to continue, or check your task configuration`)}
  22. `
  23. const RESTORE_STASH_EXAMPLE = ` Any lost modifications can be restored from a git stash:
  24. > git stash list
  25. stash@{0}: automatic lint-staged backup
  26. > git stash apply --index stash@{0}
  27. `
  28. const CONFIG_STDIN_ERROR = 'Error: Could not read config from stdin.'
  29. module.exports = {
  30. NOT_GIT_REPO,
  31. FAILED_GET_STAGED_FILES,
  32. NO_STAGED_FILES,
  33. NO_TASKS,
  34. skippingBackup,
  35. DEPRECATED_GIT_ADD,
  36. TASK_ERROR,
  37. SKIPPED_GIT_ERROR,
  38. GIT_ERROR,
  39. PREVENTED_EMPTY_COMMIT,
  40. RESTORE_STASH_EXAMPLE,
  41. CONFIG_STDIN_ERROR,
  42. }