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

[fix] minor fixes #18

Merged
merged 3 commits into from
Nov 12, 2018
Merged
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
14 changes: 11 additions & 3 deletions lib/feedsme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ Feedsme.prototype.triggerDep = async function triggerDep({ publish, env, pkg })
// NOTE: this version can be innaccurate if the npm publish was done with
// a tag that !== latest. We should handle this case at some point.
if (publish) {
this.log.info('create release-line', spec);
await this.release.create(spec);
if (spec.previousVersion === spec.version) {
this.log.warn(`${name}@${version} already has release-line, ignoring release-line create`);
} else {
this.log.info('create release-line', spec);
await this.release.create(spec);
}
}

this.log.debug(`Trying to rebuild the dependents of ${ name }`);
Expand Down Expand Up @@ -309,7 +313,11 @@ Feedsme.prototype._triggerStrategy = function _triggerStrategy({ releaseLine, ro

const { name, version: rootVersion } = rootPkg;
const { dependencies } = pkg;
const rootRange = dependencies[name];

let rootRange = dependencies[name];
// Support legacy 'latest' and alias it to * so it doesnt fail semver.satisifes
if (rootRange === 'latest') rootRange = '*';

const rootDepVersion = semver.coerce(rootRange) || releaseLine.version;

//
Expand Down
31 changes: 31 additions & 0 deletions test/feedsme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ describe('feedsme', function () {
});
});

describe('#_triggerStrategy', function () {
it('resolves latest version correctly as * and shows any version as inclusive', function () {
const rootPkg = { name: 'what', version: '6.0.1' };
const pkg = { dependencies: { [rootPkg.name]: 'latest' }};
const releaseLine = { version: '6.0.1' };
const env = 'dev';

const { strategy, trigger } = fme._triggerStrategy({ rootPkg, pkg, releaseLine, env });
assume(strategy).is.equal('current');
assume(trigger).is.equal(true);
});
});

describe('#resolve', function () {
it('only adds private dependencies to dependend', async function () {
await fme.resolve('dev', fixtures.parent);
Expand Down Expand Up @@ -266,6 +279,24 @@ describe('feedsme', function () {

fme.trigger('dev', fixtures.dependentPayloadPublished).then(next.bind(null, null), next);
});

it('does not create a new release line when previous release.version is the same', async function () {
const prevRelease = {
pkg: fixtures.dependent.name,
version: fixtures.dependent.version
};

sinon.stub(fme, 'triggerDepOf').resolves();
const warnSpy = sinon.spy(fme.log, 'warn');
sinon.stub(fme.models.Dependent, 'get').resolves({ dependents: [] });
sinon.stub(fme.release, 'get').resolves(prevRelease);
const rcreate = sinon.stub(fme.release, 'create').resolves();
await fme.trigger('dev', fixtures.dependentPayloadPublished);

assume(rcreate).is.not.called();
assume(warnSpy).is.calledWith('[email protected] already has release-line, ignoring release-line create');
sinon.restore();
});
});

describe('#change', function () {
Expand Down