UNPKG

1.71 kBJavaScriptView Raw
1'use strict'
2
3const chalk = require('chalk')
4const { error, info, warning } = require('log-symbols')
5
6const NOT_GIT_REPO = chalk.redBright(`${error} Current directory is not a git directory!`)
7
8const FAILED_GET_STAGED_FILES = chalk.redBright(`${error} Failed to get staged files!`)
9
10const NO_STAGED_FILES = `${info} No staged files found.`
11
12const NO_TASKS = `${info} No staged files match any configured task.`
13
14const 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
19const 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
24const TASK_ERROR = 'Skipped because of errors from tasks.'
25
26const SKIPPED_GIT_ERROR = 'Skipped because of previous git error.'
27
28const GIT_ERROR = `\n ${error} ${chalk.red(`lint-staged failed due to a git error.`)}`
29
30const 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
35const 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
42module.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}