Created
April 12, 2016 01:55
-
-
Save hoorayimhelping/f83fdaf749bbc26dc6676627c056d5db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| commit 55b124311c6426425e0c75d0ed7109314d8bc13f | |
| Author: Bucky Schwarz <d.w.schwarz@gmail.com> | |
| Date: Mon Apr 11 21:54:10 2016 -0400 | |
| Simple versioning on the readme | |
| diff --git a/README.md b/README.md | |
| index a960b8f..a90ee46 100644 | |
| --- a/README.md | |
| +++ b/README.md | |
| @@ -4,6 +4,8 @@ | |
| [](https://circleci.com/gh/quartethealth/qh-common) | |
| +[](https://github.com/quartethealth/qh-common/releases/latest) | |
| + | |
| --- | |
| # [Styleguide](https://quartet-health.gitbooks.io/styleguide/content/) | |
| diff --git a/package.json b/package.json | |
| index 706b9e6..7ecdee2 100644 | |
| --- a/package.json | |
| +++ b/package.json | |
| @@ -1,11 +1,11 @@ | |
| { | |
| "name": "qh-common", | |
| - "version": "2.5.6", | |
| + "version": "2.5.7", | |
| "description": "Shared components, configs, and more.", | |
| "private": true, | |
| "scripts": { | |
| "test": "nyc ava --fail-fast --verbose --require babel-core/register", | |
| - "lint": "eslint utils server test/utils", | |
| + "lint": "eslint utils server test/utils version.sh", | |
| "coveralls": "nyc report --reporter=text-lcov | coveralls" | |
| }, | |
| "dependencies": { | |
| diff --git a/version_write.sh b/version_write.sh | |
| new file mode 100755 | |
| index 0000000..db371fd | |
| --- /dev/null | |
| +++ b/version_write.sh | |
| @@ -0,0 +1,28 @@ | |
| +#!/usr/bin/env node | |
| +var fs = require('fs'); | |
| + | |
| +var PACKAGE_FILE_LOCATION = './package.json'; | |
| +var README_FILE_LOCATION = './README.md'; | |
| +var SHIELDS_IO_API_URL = 'https://img.shields.io/badge/version-'; | |
| +var SHIELDS_IO_API_URL_REGEX = /(https:\/\/img\.shields\.io\/badge\/version-)\d\.\d\.\d/ig; | |
| + | |
| +var packageFile = fs.readFileSync(PACKAGE_FILE_LOCATION); | |
| +var readmeFile = fs.readFileSync(README_FILE_LOCATION); | |
| + | |
| +if (packageFile) { | |
| + var packageContents = JSON.parse(packageFile); | |
| + var semver = packageContents['version']; | |
| + | |
| + if (readmeFile) { | |
| + var readmeContents = readmeFile.toString(); | |
| + var readmeSplitOnDashes = readmeContents.split('---'); | |
| + var heading = readmeSplitOnDashes[0]; | |
| + | |
| + var imageUrl = SHIELDS_IO_API_URL + semver; | |
| + | |
| + readmeSplitOnDashes[0] = heading.replace(SHIELDS_IO_API_URL_REGEX, imageUrl); | |
| + var readmeFileAsString = readmeSplitOnDashes.join("---"); | |
| + | |
| + fs.writeFileSync(README_FILE_LOCATION, readmeFileAsString); | |
| + } | |
| +} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment