Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"baseUrl": ".",
"target": "es6",
"module": "commonjs",
"paths": {
"@components/*": ["./src/components/*"],
"@constants/*": ["./src/constants/*"],
"@helpers/*": ["./src/helpers/*"]
}
},
"typeAcquisition": {
"include": ["jest"]
},
"include": ["src/**/*"]
}
7 changes: 4 additions & 3 deletions src/commands/amend.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ export default () => {

const { coAuthors } = pairingConfig
const trailers = coAuthoringTrailers(coAuthors)
const rawCommitMessage = stripCoAuthorship(run('git log -1 --pretty=%B'))
const command = `GITPAIR_RUNNING=1 git commit --amend -m"${rawCommitMessage}\n\n${trailers}"`
const rawCommitMessage = stripCoAuthorship(run('git', 'log', '-1', '--pretty=%B'))

log(bold('Rewriting last commit with the following info:'))
log(trailers)
run(command)
run('git', ['commit', '--amend', `${rawCommitMessage}\n\n${trailers}`], {
GITPAIR_RUNNING: 1,
})
log(bold('👥 Last commit was rewritten! 😎'))
}
16 changes: 16 additions & 0 deletions src/utils/__tests__/run.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import run from '../run'

it('run a command and returns its output', () => {
expect(run('echo', ['toto'])).toEqual('toto')
})

it('properly escapes arguments', () => {
const commitMessage = `feat(seoblock): add "search for more" tip in default select options`
expect(run('printf', ['[%s]', commitMessage])).toEqual(
'[feat(seoblock): add "search for more" tip in default select options]'
)
})

it('passes optional ENV variables to the process', () => {
expect(run('sh', ['-c', 'echo $VAR'], { VAR: 'toto' })).toEqual('toto')
})
7 changes: 5 additions & 2 deletions src/utils/run.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { execSync } from 'child_process'
import { spawnSync } from 'child_process'

export default (command) => execSync(command).toString().trim()
export default (command, args, env) =>
spawnSync(command, args, { env: { ...process.env, ...env } })
.stdout.toString()
.trim()