Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chg

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chg - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0

4

CHANGELOG.md

@@ -7,4 +7,8 @@ CHANGELOG

--------------------
## 0.4.0 (2019-03-13)
* Added triple hyphen support ([#9](https://github.com/heff/chg/pull/9))
## 0.3.3 (2017-12-12)

@@ -11,0 +15,0 @@ * Bumped dependecies

16

lib/chg.js

@@ -20,3 +20,4 @@ /*

var noItems = '_(none)_';
var divider = '--------------------\n\n';
var divider = '---\n\n';
var dividerRe = /\n\-{3,}\n\n/;

@@ -99,3 +100,3 @@ var ERR_NO_CHANGELOG = changeLogFile+' does not exist. Change to the directory where it does exist, or run `init` to create one in the current directory.';

chg.add = function(line, options, callback){
var contents, sections, top;
var contents, sections, top, divider;

@@ -113,2 +114,4 @@ options = options || {};

divider = contents.match(dividerRe);
// if 'noItems' is there, remove it

@@ -118,5 +121,5 @@ contents = contents.replace(unreleasedTitle + noItems + '\n', unreleasedTitle);

// split on the divider including preceding newline
sections = contents.split('\n'+divider);
sections = contents.split(dividerRe);
// add new line to the unreleased section
top = sections[0] + '* ' + line + '\n\n';
top = sections[0] + '* ' + line + '\n';

@@ -127,3 +130,2 @@ // combine new contents and write file

callback(null, line);

@@ -178,3 +180,5 @@

// add title at the top of the release section
contents = contents.replace(divider, divider + title + changes + '\n\n');
contents = contents.replace(dividerRe, function (divider) {
return divider + title + changes + '\n\n';
});

@@ -181,0 +185,0 @@ fs.writeFileSync(changeLogFile, contents, 'utf8');

{
"name": "chg",
"version": "0.3.3",
"version": "0.4.0",
"main": "lib/chg.js",

@@ -5,0 +5,0 @@ "description": "simple changelog/release history manager",

@@ -9,2 +9,6 @@ 'use strict';

var loadFixture = helpers.loadFixture;
var readChangelog = helpers.readChangelog;
var resetFixture = helpers.resetFixture;
describe('chg', function(){

@@ -24,3 +28,2 @@ var tmpDirName;

describe('#init()', function(){

@@ -43,3 +46,6 @@ var chgResult;

before(function() { addResult = chg.add('Test add'); });
before(function() {
resetFixture('init.md');
addResult = chg.add('Test add');
});

@@ -59,2 +65,3 @@ it('adds a new line to the changelog', function() {

before(function() {
resetFixture('add.md');
releaseTitle = '0.0.1';

@@ -105,2 +112,3 @@ releaseDate = '12/12/12';

before(function() {
resetFixture('release2.md');
findTitle = '0.0.2';

@@ -123,4 +131,2 @@ findResult = chg.find(findTitle);

});
it
});

@@ -130,2 +136,3 @@

before(function() {
resetFixture('release2.md');
chg.delete();

@@ -132,0 +139,0 @@ });

@@ -7,3 +7,3 @@ CHANGELOG

--------------------
---

@@ -8,3 +8,3 @@ CHANGELOG

--------------------
---

@@ -11,0 +11,0 @@ ## 0.0.1 (12/12/12)

@@ -7,3 +7,3 @@ CHANGELOG

--------------------
---

@@ -7,3 +7,3 @@ CHANGELOG

--------------------
---

@@ -10,0 +10,0 @@ ## 0.0.1 (12/12/12)

@@ -7,3 +7,3 @@ CHANGELOG

--------------------
---

@@ -10,0 +10,0 @@ ## 0.0.2 (12/13/12)

@@ -5,13 +5,13 @@ 'use strict';

function loadFixture(fileName) {
exports.loadFixture = function(fileName) {
return fs.readFileSync('../test/fixtures/'+fileName, 'utf8');
}
function readChangelog() {
exports.readChangelog = function() {
return fs.readFileSync('./CHANGELOG.md', 'utf8');
}
// These helpers are only used in the test suite, so we'll add them to the
// global namespace to avoid having to retype helpers every time.
global.loadFixture = module.exports['loadFixture'] = loadFixture;
global.readChangelog = module.exports['readChangelog'] = readChangelog;
exports.resetFixture = function(fileName) {
var content = fs.readFileSync('../test/fixtures/'+fileName, 'utf8');
return fs.writeFileSync('./CHANGELOG.md', content, 'utf8');
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc