Skip to content

Commit

Permalink
Merge pull request #10 from Updater/bug/package-path-matcher
Browse files Browse the repository at this point in the history
Bug/package path matcher
  • Loading branch information
pmowrer authored Dec 12, 2017
2 parents aaf7b74 + 2eed430 commit f34137f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"semantic-release": "^11.0.0"
},
"dependencies": {
"debug": "^3.1.0",
"execa": "^0.8.0",
"pkg-up": "^2.0.0",
"ramda": "^0.25.0",
Expand Down
2 changes: 1 addition & 1 deletion src/get-last-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = async (pluginConfig, options) => {
* 2. We can use `semantic-release`'s fallback strategy, searching for a matching git tag,
* but we must update the git tag format to be compatible with the monorepo workflow.
**/
if (!result.gitHead) {
if (result && !result.gitHead) {
return {
...result,
...await getVersionHead(null, await gitTag(result.version))
Expand Down
12 changes: 11 additions & 1 deletion src/with-package-commits.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const debug = require('debug')('semantic-release:commit-analyzer');
const pkgUp = require('pkg-up');
const { getCommitFiles, getGitRoot } = require('./git-utils');
const overrideOption = require('./override-option');
Expand All @@ -17,10 +18,19 @@ const withFiles = async commits => {

const withPackageCommits = async commits => {
const packagePath = await getPackagePath();
debug('Filter commits by package path: "%s"', packagePath);
const commitsWithFiles = await withFiles(commits);

return commitsWithFiles.filter(
({ files }) => files.some(path => path.includes(packagePath))
({ files, subject }) => {
const matchingPath = files.find(path => path.indexOf(packagePath) === 0);

if (matchingPath) {
debug('Including commit "%s" because it modified package file "%s".', subject, matchingPath);
}

return !!matchingPath;
}
);
};

Expand Down

0 comments on commit f34137f

Please sign in to comment.