Skip to content

chore(changelog): fix missing module for adding streams #1738

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

Merged
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
21 changes: 0 additions & 21 deletions scripts/e2e.sh

This file was deleted.

37 changes: 22 additions & 15 deletions scripts/release/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

const fs = require('fs');
const addStream = require('add-stream');
const merge2 = require('merge2');
const changelog = require('conventional-changelog');
const spawnSync = require('child_process').spawnSync;
const npmVersion = require('../../package.json').version;
Expand All @@ -17,7 +17,7 @@ const npmVersion = require('../../package.json').version;
* By default, it will only create the changelog from the latest tag to head and prepends it to the changelog.
*/
const isForce = process.argv.indexOf('--force') !== -1;
const inStream = fs.createReadStream('CHANGELOG.md');
const previousChangelog = fs.createReadStream('CHANGELOG.md');
const gitTags = getAvailableTags();

// Whether the npm version is later than the most recent tag.
Expand All @@ -27,33 +27,40 @@ const currentTag = isNpmLatest ? npmVersion : gitTags[0];
// When the npm version is the latest use the most recent tag. Otherwise use the previous tag.
const previousTag = isNpmLatest ? gitTags[0] : gitTags[1];

inStream.on('error', function(err) {
console.error('An error occurred, while reading the previous changelog file.\n' +
'If there is no previous changelog, then you should create an empty file or use the `--force` flag.\n' + err);
if (!isForce) {
previousChangelog.on('error', function(err) {
console.error('An error occurred, while reading the previous changelog file.\n' +
'If there is changelog file, you should create an empty file or use the `--force` flag.\n' + err);

process.exit(1);
});
process.exit(1);
});
}

var config = {
const config = {
preset: 'angular',
releaseCount: isForce ? 0 : 1
};

var context = {
const context = {
currentTag: currentTag,
previousTag: previousTag
};

var stream = changelog(config, context)
.on('error', function(err) {
console.error('An error occurred while generating the changelog: ' + err);
})
.pipe(!isForce && addStream(inStream) || getOutputStream());
let stream = changelog(config, context).on('error', function(err) {
console.error('An error occurred while generating the changelog: ' + err);
});

if (!isForce) {
// Append the previous changelog to the new generated one.
stream = merge2(stream, previousChangelog);
} else {
stream.pipe(getOutputStream())
}

// When we are pre-pending the new changelog, then we need to wait for the input stream to be ending,
// otherwise we can't write into the same destination.
if (!isForce) {
inStream.on('end', function() {
previousChangelog.on('end', function() {
stream.pipe(getOutputStream());
});
}
Expand Down