UNPKG

1.8 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
42const CONFIG_STDIN_ERROR = 'Error: Could not read config from stdin.'
43
44module.exports = {
45 NOT_GIT_REPO,
46 FAILED_GET_STAGED_FILES,
47 NO_STAGED_FILES,
48 NO_TASKS,
49 skippingBackup,
50 DEPRECATED_GIT_ADD,
51 TASK_ERROR,
52 SKIPPED_GIT_ERROR,
53 GIT_ERROR,
54 PREVENTED_EMPTY_COMMIT,
55 RESTORE_STASH_EXAMPLE,
56 CONFIG_STDIN_ERROR,
57}