Skip to content

Commit 640dbb6

Browse files
devversionjelbourn
authored andcommitted
chore(changelog): fix missing module for adding streams (#1738)
1 parent 4203d09 commit 640dbb6

File tree

2 files changed

+22
-36
lines changed

2 files changed

+22
-36
lines changed

scripts/e2e.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

scripts/release/changelog.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

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

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

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

34-
process.exit(1);
35-
});
35+
process.exit(1);
36+
});
37+
}
3638

37-
var config = {
39+
const config = {
3840
preset: 'angular',
3941
releaseCount: isForce ? 0 : 1
4042
};
4143

42-
var context = {
44+
const context = {
4345
currentTag: currentTag,
4446
previousTag: previousTag
4547
};
4648

47-
var stream = changelog(config, context)
48-
.on('error', function(err) {
49-
console.error('An error occurred while generating the changelog: ' + err);
50-
})
51-
.pipe(!isForce && addStream(inStream) || getOutputStream());
49+
let stream = changelog(config, context).on('error', function(err) {
50+
console.error('An error occurred while generating the changelog: ' + err);
51+
});
52+
53+
if (!isForce) {
54+
// Append the previous changelog to the new generated one.
55+
stream = merge2(stream, previousChangelog);
56+
} else {
57+
stream.pipe(getOutputStream())
58+
}
5259

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

0 commit comments

Comments
 (0)