keep-a-changelog
Advanced tools
Comparing version 0.5.2 to 0.6.0
22
bin.js
@@ -6,3 +6,3 @@ #!/usr/bin/env node | ||
const url = require('url'); | ||
const { parser } = require('./src'); | ||
const { parser, Changelog, Release } = require('./src'); | ||
const argv = require('yargs-parser')(process.argv.slice(2), { | ||
@@ -14,3 +14,3 @@ default: { | ||
}, | ||
boolean: ['https'] | ||
boolean: ['https', 'init'] | ||
}); | ||
@@ -21,2 +21,11 @@ | ||
try { | ||
if (argv.init) { | ||
const changelog = new Changelog('Changelog').addRelease( | ||
new Release('0.1.0', new Date(), 'First version') | ||
); | ||
save(file, changelog, true); | ||
process.exit(0); | ||
} | ||
const changelog = parser(fs.readFileSync(file, 'UTF-8')); | ||
@@ -66,5 +75,10 @@ | ||
function save(file, changelog) { | ||
function save(file, changelog, isNew) { | ||
fs.writeFileSync(file, changelog.toString()); | ||
console.log(green('Updated file'), file); | ||
if (isNew) { | ||
console.log(green('Generated new file'), file); | ||
} else { | ||
console.log(green('Updated file'), file); | ||
} | ||
} | ||
@@ -71,0 +85,0 @@ |
@@ -8,2 +8,8 @@ # Changelog | ||
## [0.6.0] - 2018-06-12 | ||
### Added | ||
- CLI Api: New option `--init`, to generate an empty CHANGELOG.md file | ||
## [0.5.2] - 2018-05-12 | ||
@@ -87,2 +93,3 @@ | ||
[0.6.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.2...v0.6.0 | ||
[0.5.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.1...v0.5.2 | ||
@@ -89,0 +96,0 @@ [0.5.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.0...v0.5.1 |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/oscarotero/keep-a-changelog#readme", | ||
"version": "0.5.2", | ||
"version": "0.6.0", | ||
"main": "src/index.js", | ||
@@ -34,4 +34,4 @@ "bin": { | ||
"devDependencies": { | ||
"mocha": "^5.0.4", | ||
"prettier": "^1.11.1" | ||
"mocha": "^5.2.0", | ||
"prettier": "^1.13.5" | ||
}, | ||
@@ -38,0 +38,0 @@ "scripts": { |
@@ -16,7 +16,7 @@ # keep-a-changelog | ||
```js | ||
const { parse } = require('keep-a-changelog'); | ||
const { parser } = require('keep-a-changelog'); | ||
const fs = require('fs'); | ||
//Parse a changelog file | ||
const changelog = parse(fs.readFileSync('CHANGELOG.md', 'UTF-8')); | ||
const changelog = parser(fs.readFileSync('CHANGELOG.md', 'UTF-8')); | ||
@@ -63,2 +63,8 @@ //Generate the new changelog string | ||
To generate an empty new CHANGELOG.md file: | ||
```sh | ||
changelog --init | ||
``` | ||
Available options: | ||
@@ -71,1 +77,2 @@ | ||
`--https` | Set to false to use `http` instead `https` in the url (`--https=false`). | ||
`--init` | Init a new empty changelog file. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32388
457
76