Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Add update checking #8

Merged
merged 1 commit into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Options:

* Fix examples not showing in `--help`
* Move build and plugin dir from `/tmp/bkrun` to `~/.bkrun`
* Check for new updated versions using [update-check](https://github.com/zeit/update-check)
* Self-contained binaries to GitHub release using [pkg](https://www.npmjs.com/package/pkg)
* Homebrew

Expand Down
8 changes: 5 additions & 3 deletions bin/bksr.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env node

const pkg = require('../package')
const cli = require('../lib/cli')
const pkg = require('../package.json')
const yargs = require('yargs')
const updateCheck = require('../lib/update-check')

const argv = require('yargs')
const argv = yargs
.usage('$0', pkg.description)
.option('step', {
describe: 'Label of the step to run',
Expand Down Expand Up @@ -50,7 +52,7 @@ const argv = require('yargs')
.help()
.argv

cli(argv)
updateCheck().then(() => cli(argv))

process.on('unhandledRejection', (err) => {
console.error(err)
Expand Down
1 change: 1 addition & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const promptForStep = (pipeline) => (
)

const cli = ({ pipeline: pipelinePath, step: stepNameArg, all, branch, checkout }) => (

readPipeline(pipelinePath)
.then(pipeline => {
if (all && !branch) {
Expand Down
10 changes: 10 additions & 0 deletions lib/update-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const pkg = require('../package')
const checkForUpdate = require('update-check')

module.exports = async () => {
const update = await checkForUpdate(pkg)

if (update) {
console.log(`The latest version is ${update.latest}. Please update:\nnpm install -g bksr`)
}
}
60 changes: 56 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"get-stdin": "^6.0.0",
"inquirer": "^5.2.0",
"js-yaml": "^3.11.0",
"update-check": "^1.4.0",
"yargs": "^11.0.0"
},
"devDependencies": {
Expand Down