'use strict'

var execSync = require('child_process').execSync

module.exports = function (cwd) {
	var command = 'git log --pretty=oneline'
	if (cwd) {
		command = 'cd ' + cwd + ' && ' + command
	}

	var result = execSync(command).toString()
	return result
		.split('\n')[0]
		.split(' ')
}

'use strict'

var execSync = require('child_process').execSync

module.exports = function (cwd) {
	var command = 'git log --pretty=oneline'
	var result = execSync(command, { cwd: cwd }).toString()
	return result
		.split('\n')[0]
		.split(' ')
}

Use the cwd option to set the cwd
Use the cwd option to set the cwd

`exec` and `execSync` allow to pass an options object in the second argument. We can use `cwd` to set the directory where to run the command.