Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add full support for SEMANTIC_RELEASE_PACKAGE, non-JS packages #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const readPkg = require('read-pkg');
const { compose } = require('ramda');
const withOnlyPackageCommits = require('./only-package-commits');
const versionToGitTag = require('./version-to-git-tag');
const logPluginVersion = require('./log-plugin-version');
const { getPackageInfoSync } = require('./package-info');
const { wrapStep } = require('semantic-release-plugin-decorators');

const {
Expand Down Expand Up @@ -59,5 +59,5 @@ module.exports = {
generateNotes,
success,
fail,
tagFormat: readPkg.sync().name + '-v${version}',
tagFormat: getPackageInfoSync().name + '-v${version}',
};
6 changes: 3 additions & 3 deletions src/only-package-commits.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { identity, memoizeWith, pipeP } = require('ramda');
const pkgUp = require('pkg-up');
const readPkg = require('read-pkg');
const path = require('path');
const pLimit = require('p-limit');
const debug = require('debug')('semantic-release:monorepo');
const { getCommitFiles, getRoot } = require('./git-utils');
const { getPackageInfo } = require('./package-info');
const { mapCommits } = require('./options-transforms');

const memoizedGetCommitFiles = memoizeWith(identity, getCommitFiles);
Expand All @@ -13,7 +13,7 @@ const memoizedGetCommitFiles = memoizeWith(identity, getCommitFiles);
* Get the normalized PACKAGE root path, relative to the git PROJECT root.
*/
const getPackagePath = async () => {
const packagePath = await pkgUp();
const packagePath = await pkgUp() || './package.json';
const gitRoot = await getRoot();

return path.relative(gitRoot, path.resolve(packagePath, '..'));
Expand Down Expand Up @@ -68,7 +68,7 @@ const tapA = fn => async x => {
};

const logFilteredCommitCount = logger => async ({ commits }) => {
const { name } = await readPkg();
const { name } = await getPackageInfo();

logger.log(
'Found %s commits for package %s since last release',
Expand Down
14 changes: 14 additions & 0 deletions src/package-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const readPkg = require('read-pkg');

const getPackageInfo = async () => ({
name: process.env.SEMANTIC_RELEASE_PACKAGE || (await readPkg()).name,
});

const getPackageInfoSync = () => ({
name: process.env.SEMANTIC_RELEASE_PACKAGE || readPkg.sync().name,
});

module.exports = {
getPackageInfo,
getPackageInfoSync,
};
4 changes: 2 additions & 2 deletions src/version-to-git-tag.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const readPkg = require('read-pkg');
const { getPackageInfo } = require('./package-info')

module.exports = async version => {
if (!version) {
return null;
}

const { name } = await readPkg();
const name = (await getPackageInfo()).name;
return `${name}-v${version}`;
};