UNPKG

2.28 kBJavaScriptView Raw
1import { redBright, bold, yellow } from 'colorette'
2import inspect from 'object-inspect'
3
4import { error, info, warning } from './figures.js'
5
6export const configurationError = (opt, helpMsg, value) =>
7 `${redBright(`${error} Validation Error:`)}
8
9 Invalid value for '${bold(opt)}': ${bold(
10 inspect(value, { inlineCharacterLimit: Number.POSITIVE_INFINITY })
11 )}
12
13 ${helpMsg}`
14
15export const NOT_GIT_REPO = redBright(`${error} Current directory is not a git directory!`)
16
17export const FAILED_GET_STAGED_FILES = redBright(`${error} Failed to get staged files!`)
18
19export const incorrectBraces = (before, after) =>
20 yellow(
21 `${warning} Detected incorrect braces with only single value: \`${before}\`. Reformatted as: \`${after}\`
22`
23 )
24
25export const NO_STAGED_FILES = `${info} No staged files found.`
26
27export const NO_TASKS = `${info} No staged files match any configured task.`
28
29export const skippingBackup = (hasInitialCommit) => {
30 const reason = hasInitialCommit ? '`--no-stash` was used' : 'there’s no initial commit yet'
31 return yellow(`${warning} Skipping backup because ${reason}.\n`)
32}
33
34export const DEPRECATED_GIT_ADD = yellow(
35 `${warning} 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.
36`
37)
38
39export const TASK_ERROR = 'Skipped because of errors from tasks.'
40
41export const SKIPPED_GIT_ERROR = 'Skipped because of previous git error.'
42
43export const GIT_ERROR = `\n ${redBright(`${error} lint-staged failed due to a git error.`)}`
44
45export const invalidOption = (name, value, message) => `${redBright(`${error} Validation Error:`)}
46
47 Invalid value for option '${bold(name)}': ${bold(value)}
48
49 ${message}
50
51See https://github.com/okonet/lint-staged#command-line-flags`
52
53export const PREVENTED_EMPTY_COMMIT = `
54 ${yellow(`${warning} lint-staged prevented an empty git commit.
55 Use the --allow-empty option to continue, or check your task configuration`)}
56`
57
58export const RESTORE_STASH_EXAMPLE = ` Any lost modifications can be restored from a git stash:
59
60 > git stash list
61 stash@{0}: automatic lint-staged backup
62 > git stash apply --index stash@{0}
63`
64
65export const CONFIG_STDIN_ERROR = 'Error: Could not read config from stdin.'