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