Read commit messages from a specified range or disk
npm install --save @commitlint/read
type Range = {
/* Lower end of the commit range to read */
from: string;
/* Upper end of the commit range to read */
to: string;
/* Whether (boolean) to read from ./.git/COMMIT_EDITMSG or where to read from (string) */
edit?: boolean | string;
};
read(range: Range) => Promise<string[]>
import read from '@commitlint/read';
Consider to have a repository with two commits:
- Initial commit
- I did something
const result = await read({edit: true});
console.info(result);
// => ['I did something\n\n']
const result = await read({from: 'HEAD~2'});
console.info(result);
// => ['I did something\n\n', 'Initial commit\n\n']
const result = await read({from: 'HEAD~2', to: 'HEAD~1'});
console.info(result);
// => ['Initial commit\n\n']
const result = await read({edit: './git/GITGUI_EDITMESSAGE'});
console.info(result);
// => ['I did something via git gui\n\n']