Closed
Description
Description
Steps to reproduce
- Create an Angular project
npm i -D husky prettier lint-staged
npx husky install
- Add to
package.json
"lint-staged": {
"*.{ts,js}": [
"prettier --write",
"npm run lint"
],
"*.{scss,html,json}": "prettier --write"
}
- Modify a TS file and commit.
- See an error along the lines of
An unhandled exception occurred: Project '/home/maxie/Projects/ng-git-hooks/src/app/app.component.ts' does not exist.
.
Here's a repo where I tried to get hooks to work (note the branch): https://github.com/Berkmann18/ng-git-hooks/tree/husky-ls
Debug Logs
expand to view
lint-staged:bin Running `[email protected]` +0ms
lint-staged:bin Options parsed from command-line: {
allowEmpty: false,
concurrent: true,
configPath: undefined,
debug: true,
maxArgLength: 65536,
stash: true,
quiet: false,
relative: false,
shell: false,
verbose: false
} +1ms
lint-staged Loading config using `cosmiconfig` +0ms
lint-staged Successfully loaded config from `/home/maxie/Projects/ng-git-hooks/package.json`:
lint-staged {
lint-staged '*.{ts,js}': [ 'prettier --write', 'npm run lint' ],
lint-staged '*.{scss,html,json}': 'prettier --write'
lint-staged } +12ms
lint-staged:cfg Validating config +0ms
Running lint-staged with the following config:
{
'*.{ts,js}': [
'prettier --write',
'npm run lint'
],
'*.{scss,html,json}': 'prettier --write'
}
lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +2ms
lint-staged:run Running all linter scripts +0ms
lint-staged:resolveGitRepo Resolving git repo from `/home/maxie/Projects/ng-git-hooks` +0ms
lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +0ms
lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ] +0ms
lint-staged:resolveGitRepo Resolved git directory to be `/home/maxie/Projects/ng-git-hooks` +11ms
lint-staged:resolveGitRepo Resolved git config directory to be `/home/maxie/Projects/ng-git-hooks/.git` +1ms
lint-staged:git Running git command [ 'log', '-1' ] +12ms
lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only', '-z' ] +3ms
lint-staged:run Loaded list of staged files in git:
lint-staged:run [ 'src/app/app.component.ts' ] +20ms
lint-staged:chunkFiles Resolved an argument string length of 58 characters from 1 files +0ms
lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 65536 +0ms
lint-staged:gen-tasks Generating linter tasks +0ms
lint-staged:gen-tasks Generated task:
lint-staged:gen-tasks {
lint-staged:gen-tasks pattern: '*.{ts,js}',
lint-staged:gen-tasks commands: [ 'prettier --write', 'npm run lint' ],
lint-staged:gen-tasks fileList: [ '/home/maxie/Projects/ng-git-hooks/src/app/app.component.ts' ]
lint-staged:gen-tasks } +3ms
lint-staged:gen-tasks Generated task:
lint-staged:gen-tasks {
lint-staged:gen-tasks pattern: '*.{scss,html,json}',
lint-staged:gen-tasks commands: 'prettier --write',
lint-staged:gen-tasks fileList: []
lint-staged:gen-tasks } +0ms
lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'prettier --write', 'npm run lint' ] +0ms
lint-staged:task cmd: prettier +0ms
lint-staged:task args: [ '--write' ] +0ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
lint-staged:task cmd: npm +0ms
lint-staged:task args: [ 'run', 'lint' ] +0ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
lint-staged:make-cmd-tasks Creating listr tasks for commands 'prettier --write' +2ms
lint-staged:task cmd: prettier +1ms
lint-staged:task args: [ '--write' ] +0ms
lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
lint-staged:chunkFiles Resolved an argument string length of 58 characters from 1 files +7ms
lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 65536 +0ms
[STARTED] Preparing...
lint-staged:git Backing up original state... +0ms
lint-staged:git Getting partially staged files... +0ms
lint-staged:git Running git command [ 'status', '-z' ] +15ms
lint-staged:git Found partially staged files: [] +4ms
lint-staged:git Backing up merge state... +1ms
lint-staged:file Reading file `/home/maxie/Projects/ng-git-hooks/.git/MERGE_HEAD` +0ms
lint-staged:file Reading file `/home/maxie/Projects/ng-git-hooks/.git/MERGE_MODE` +0ms
lint-staged:file Reading file `/home/maxie/Projects/ng-git-hooks/.git/MERGE_MSG` +0ms
lint-staged:file File `/home/maxie/Projects/ng-git-hooks/.git/MERGE_HEAD` doesn't exist, ignoring... +1ms
lint-staged:file File `/home/maxie/Projects/ng-git-hooks/.git/MERGE_MODE` doesn't exist, ignoring... +0ms
lint-staged:file File `/home/maxie/Projects/ng-git-hooks/.git/MERGE_MSG` doesn't exist, ignoring... +0ms
lint-staged:git Done backing up merge state! +1ms
lint-staged:git Getting deleted files... +0ms
lint-staged:git Running git command [ 'ls-files', '--deleted' ] +6ms
lint-staged:git Found deleted files: [] +5ms
lint-staged:git Running git command [ 'stash', 'create' ] +5ms
lint-staged:git Running git command [
'stash',
'store',
'--quiet',
'--message',
'lint-staged automatic backup',
'85cecc1bdb737fa2a8702c405246999fe66e993d'
] +6ms
lint-staged:git Done backing up original state! +11ms
[SUCCESS] Preparing...
[STARTED] Running tasks...
[STARTED] Running tasks for *.{ts,js}
[STARTED] Running tasks for *.{scss,html,json}
[SKIPPED] No staged files match *.{scss,html,json}
[STARTED] prettier --write
[SUCCESS] prettier --write
[STARTED] npm run lint
[FAILED] npm run lint [FAILED]
[FAILED] npm run lint [FAILED]
[SUCCESS] Running tasks...
[STARTED] Applying modifications...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
lint-staged:git Restoring original state... +965ms
lint-staged:git Running git command [ 'reset', '--hard', 'HEAD' ] +970ms
lint-staged:git Running git command [ 'stash', 'list' ] +5ms
lint-staged:git Running git command [ 'stash', 'apply', '--quiet', '--index', 'refs/stash@{0}' ] +5ms
lint-staged:git Restoring merge state... +22ms
lint-staged:git Done restoring merge state! +0ms
lint-staged:file Removing file `/home/maxie/Projects/ng-git-hooks/.git/lint-staged_unstaged.patch` +1s
lint-staged:file File `/home/maxie/Projects/ng-git-hooks/.git/lint-staged_unstaged.patch` doesn't exist, ignoring... +1ms
lint-staged:git Done restoring original state! +1ms
[SUCCESS] Reverting to original state because of errors...
[STARTED] Cleaning up...
lint-staged:git Dropping backup stash... +0ms
lint-staged:git Running git command [ 'stash', 'list' ] +13ms
lint-staged:git Running git command [ 'stash', 'drop', '--quiet', 'refs/stash@{0}' ] +4ms
lint-staged:git Done dropping backup stash! +10ms
[SUCCESS] Cleaning up...
✖ npm run lint:
An unhandled exception occurred: Project '/home/maxie/Projects/ng-git-hooks/src/app/app.component.ts' does not exist.
See "/tmp/ng-TUhhkl/angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] lint: `ng lint "/home/maxie/Projects/ng-git-hooks/src/app/app.component.ts"`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/maxie/.npm/_logs/2021-02-12T21_11_30_310Z-debug.log
> [email protected] lint /home/maxie/Projects/ng-git-hooks
> ng lint "/home/maxie/Projects/ng-git-hooks/src/app/app.component.ts"
Environment
- OS: ArchLinux
- Node.js: v14.11.0
lint-staged
: 10.5.4
Metadata
Metadata
Assignees
Labels
No labels
Activity