Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
Get git root directory + pass to changelog function (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
deroke authored and bitionaire committed Nov 29, 2018
1 parent 20d4dc6 commit 5064598
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const verifyChangelogDirectory = (directory) => {
}
};

const getGitRootDirectory = () => {
return spawnSync( 'git', [ 'rev-parse', '--show-toplevel' ] ).stdout.toString().trim();
};

const getChronologicalCommitHashes = () => {
return spawnSync( 'git', [ '--no-pager', 'log', '--reverse', '--pretty=format:%H' ] ).stdout.toString().trim().split('\n');
};
Expand Down Expand Up @@ -239,11 +243,13 @@ const run = () => {
const changelogDir = path.resolve(process.cwd(), 'changelog');
verifyChangelogDirectory(changelogDir);

const gitRootDir = getGitRootDirectory();

// create changelog
const versionTagsToCommitHashes = getVersionTagsToCommitHashes();
const commitHashesToVersionTags = getCommitHashesToVersionTags(versionTagsToCommitHashes);
const filesToVersionTags = getFilesToVersionTags(process.cwd(), commitHashesToVersionTags);
const changelogData = getChangelogData(filesToVersionTags, program.includeDrafts, program.includeUpcoming, process.cwd());
const changelogData = getChangelogData(filesToVersionTags, program.includeDrafts, program.includeUpcoming, gitRootDir);

let changelog = '';
Object.keys(changelogData).filter(version => version !== 'undefined').sort((a, b) => {
Expand Down

0 comments on commit 5064598

Please sign in to comment.