diff --git a/src/cmds.js b/src/cmds.js index b67c4a3..296acfe 100644 --- a/src/cmds.js +++ b/src/cmds.js @@ -30,14 +30,15 @@ const runCmd = (cmd, { errorMessage = 'Skipping... {0}' } = {}) => { * @param {*|string} version * @param {object} options * @param {string} options.contextPath + * @param {string} options.releaseTypeScope * @returns {string} */ -const commitFiles = (version, { contextPath = CONTEXT_PATH } = {}) => +const commitFiles = (version, { contextPath = CONTEXT_PATH, releaseTypeScope = 'chore(release)' } = {}) => runCmd( `git add ${join(contextPath, 'package.json')} ${join(contextPath, 'CHANGELOG.md')} && git commit ${join( contextPath, 'package.json' - )} ${join(contextPath, 'CHANGELOG.md')} -m "chore(release): ${version}"`, + )} ${join(contextPath, 'CHANGELOG.md')} -m "${releaseTypeScope}: ${version}"`, 'Skipping release commit... {0}' ); @@ -56,10 +57,12 @@ const getCurrentVersion = ({ contextPath = CONTEXT_PATH } = {}) => { /** * Get last release commit hash * + * @param {object} options + * @param {string} releaseTypeScope * @returns {string} */ -const getReleaseCommit = () => - runCmd('git log --grep="chore(release)" --pretty=oneline -1', 'Skipping release commit check... {0}'); +const getReleaseCommit = ({ releaseTypeScope = 'chore(release)' } = {}) => + runCmd(`git log --grep="${releaseTypeScope}" --pretty=oneline -1`, 'Skipping release commit check... {0}'); /** * Get the repositories remote diff --git a/src/files.js b/src/files.js index cda134b..7c69857 100644 --- a/src/files.js +++ b/src/files.js @@ -11,6 +11,7 @@ const { _COMMIT_CHANGELOG_CONTEXT_PATH: CONTEXT_PATH } = global; * @param {object} options * @param {string} options.fallbackPackageVersion * @param {string} options.filePath + * @param {string} options.headerMd * @param {boolean} options.isDryRun * @returns {string} */ @@ -21,13 +22,14 @@ const updateChangelog = ( date, fallbackPackageVersion = '¯\\_(ツ)_/¯', filePath = join(CONTEXT_PATH, `/CHANGELOG.md`), + headerMd = `# Changelog\nAll notable changes to this project will be documented in this file.`, isDryRun = false } = {} ) => { const systemTimestamp = ((date && new Date(date)) || new Date()).toLocaleDateString('fr-CA', { timeZone: 'UTC' }); - let header = `# Changelog\nAll notable changes to this project will be documented in this file.`; + let header = headerMd; let body = ''; if (existsSync(filePath)) { diff --git a/tests/__snapshots__/code.test.js.snap b/tests/__snapshots__/code.test.js.snap index 352adb6..b028f9e 100644 --- a/tests/__snapshots__/code.test.js.snap +++ b/tests/__snapshots__/code.test.js.snap @@ -3,9 +3,9 @@ exports[`General code checks should only have specific console.[warn|log|info|error] methods: console methods 1`] = ` [ "cmds.js:21: console.error(color.RED, errorMessage.replace('{0}', e.message), color.NOCOLOR)", - "cmds.js:122: console.error(color.RED, \`Semver: \${e.message}\`, color.NOCOLOR)", - "cmds.js:152: console.error(color.RED, \`Semver: \${e.message}\`, color.NOCOLOR)", - "files.js:48: console.info(\` \${output}\`)", + "cmds.js:125: console.error(color.RED, \`Semver: \${e.message}\`, color.NOCOLOR)", + "cmds.js:155: console.error(color.RED, \`Semver: \${e.message}\`, color.NOCOLOR)", + "files.js:50: console.info(\` \${output}\`)", "global.js:64: console.error(color.RED, \`Conventional commit types: \${e.message}\`, color.NOCOLOR)", "index.js:40: console.info( index.js:54: console.info(color.NOCOLOR)", ]