UNPKG

2.36 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_CONFIGURATION = `${error} No valid configuration found.`
26
27export const NO_STAGED_FILES = `${info} No staged files found.`
28
29export const NO_TASKS = `${info} No staged files match any configured task.`
30
31export const skippingBackup = (hasInitialCommit) => {
32 const reason = hasInitialCommit ? '`--no-stash` was used' : 'there’s no initial commit yet'
33 return yellow(`${warning} Skipping backup because ${reason}.\n`)
34}
35
36export const DEPRECATED_GIT_ADD = yellow(
37 `${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.
38`
39)
40
41export const TASK_ERROR = 'Skipped because of errors from tasks.'
42
43export const SKIPPED_GIT_ERROR = 'Skipped because of previous git error.'
44
45export const GIT_ERROR = `\n ${redBright(`${error} lint-staged failed due to a git error.`)}`
46
47export const invalidOption = (name, value, message) => `${redBright(`${error} Validation Error:`)}
48
49 Invalid value for option '${bold(name)}': ${bold(value)}
50
51 ${message}
52
53See https://github.com/okonet/lint-staged#command-line-flags`
54
55export const PREVENTED_EMPTY_COMMIT = `
56 ${yellow(`${warning} lint-staged prevented an empty git commit.
57 Use the --allow-empty option to continue, or check your task configuration`)}
58`
59
60export const RESTORE_STASH_EXAMPLE = ` Any lost modifications can be restored from a git stash:
61
62 > git stash list
63 stash@{0}: automatic lint-staged backup
64 > git stash apply --index stash@{0}
65`
66
67export const CONFIG_STDIN_ERROR = 'Error: Could not read config from stdin.'