Skip to content

Commit

Permalink
fix: add all modified files to git index with git add .
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Nov 14, 2019
1 parent 869bac6 commit bf532c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/gitWorkflow.js
Expand Up @@ -105,7 +105,7 @@ class GitWorkflow {
debug('Detected files modified by tasks:')
debug(modifiedFiles)
debug('Adding files to index...')
await this.execGit(['add', modifiedFiles])
await this.execGit(['add', '.'])
debug('Done adding files to index!')
}

Expand Down
6 changes: 5 additions & 1 deletion test/runAll.unmocked.spec.js
Expand Up @@ -129,17 +129,21 @@ describe('runAll', () => {
})

it('Should commit entire staged file when no errors and linter modifies file', async () => {
// Stage ugly file
// Stage multiple ugly files
await appendFile('test.js', testJsFileUgly)
await execGit(['add', 'test.js'])

await appendFile('test2.js', testJsFileUgly)
await execGit(['add', 'test2.js'])

// Run lint-staged with `prettier --write` and commit pretty file
await gitCommit(fixJsConfig)

// Nothing is wrong, so a new commit is created and file is pretty
expect(await execGit(['rev-list', '--count', 'HEAD'])).toEqual('2')
expect(await execGit(['log', '-1', '--pretty=%B'])).toMatch('test')
expect(await readFile('test.js')).toEqual(testJsFilePretty)
expect(await readFile('test2.js')).toEqual(testJsFilePretty)
})

it('Should fail to commit entire staged file when errors from linter', async () => {
Expand Down

0 comments on commit bf532c2

Please sign in to comment.