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