Skip to content

Commit

Permalink
Update version script to work with Mac (#31)
Browse files Browse the repository at this point in the history
* Update version script to work with Mac

* Fix version script to add prefix "v"

* Add CHANGELOG.md to git stage after updating version
  • Loading branch information
yhatt authored May 29, 2018
1 parent b000047 commit 5abccbe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"preversion": "npm-run-all --npm-path yarn --parallel format:check lint:all test:coverage",
"test": "cross-env NODE_ENV=test mocha",
"test:coverage": "cross-env NODE_ENV=test nyc mocha",
"version": "bash version.sh",
"version": "node version.js && git add -A CHANGELOG.md",
"watch": "babel src --out-dir lib -w"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs')
const path = require('path')

const unreleased = '## [Unreleased]'
const [date] = new Date().toISOString().split('T')
const version = `## v${process.env.npm_package_version} - ${date}`

const changelog = path.resolve(__dirname, 'CHANGELOG.md')
const content = fs.readFileSync(changelog, 'utf8')

fs.writeFileSync(
changelog,
content.replace(unreleased, `${unreleased}\n\n${version}`)
)
4 changes: 0 additions & 4 deletions version.sh

This file was deleted.

0 comments on commit 5abccbe

Please sign in to comment.