diff --git a/README.md b/README.md index 31c2337..33ff1c0 100644 --- a/README.md +++ b/README.md @@ -14,35 +14,34 @@ With colors (this depends on your own configuration) and showing off language su npm install -g arch-wiki-man ``` -Or you can also install it [through the AUR](https://aur.archlinux.org/packages/arch-wiki-man/). For example, using yaourt: +Or install it [through the AUR](https://aur.archlinux.org/packages/arch-wiki-man/). For example, using yaourt: ``` yaourt -S arch-wiki-man ``` -# Updating through npm +# Update with `awman-update` -## npm +Updates are pushed automatically every two days to `https://github.com/greg-js/arch-wiki-md-repo`, a dependency for this project. -Just reinstall the package: +Fetch all changes with the `awman-update` script: ``` -npm install -g arch-wiki-man - +awman-update ``` -Updates are pushed automatically every two days to `https://github.com/greg-js/arch-wiki-md-repo`, a dependency for this project. Whenever the install command is run, arch-wiki-man will fetch the changes from arch-wiki-md-repo, giving you access to the latest changes. +Even when there are no new changes since the last update, running `awman-update` will actually reinstall the underlying repo, so you can use it in case something somehow goes wrong. + -## yaourt +# Update by reinstalling the package -Just reinstall the package (see paragraph above for explanation): +`awman-update` is faster and more convenient, but you can also get the latest changes simply by reinstalling this global package: ``` -yaourt -S arch-wiki-man +npm install -g arch-wiki-man # for npm users +yaourt -S arch-wiki-man # for AUR users (yaourt is just an example, use any helper you want) ``` -Of course you don't *have* to use yaourt for reinstalling the package, this is just an example. Use any helper you want or compile the AUR package yourself. - # Usage & Examples ## Basic diff --git a/bin/update.js b/bin/update.js new file mode 100755 index 0000000..294ded5 --- /dev/null +++ b/bin/update.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +'use strict'; + +var npmi = require('npmi'); +var path = require('path'); + +var options = { + name: 'arch-wiki-md-repo', + path: path.resolve(__dirname + '/..'), + forceInstall: true +}; + +npmi(options, function(err, result) { + if (err) { + if (err.code === npmi.LOAD_ERR) { + console.log('npm load error'); + } + else if (err.code === npmi.INSTALL_ERR) { + console.log('npm install error'); + } + return console.log(err.message); + } + + console.log(options.name + ' has been successfully updated or reinstalled.'); +}); \ No newline at end of file diff --git a/package.json b/package.json index 83614c1..f9c8e12 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,11 @@ "description": "The Arch Wiki as linux man pages", "main": "index.js", "bin": { - "awman": "bin/find.js" + "awman": "bin/find.js", + "awman-update": "bin/update.js" }, "scripts": { - "test": "./node_modules/mocha/bin/mocha ./test", - "update": "npm update arch-wiki-md-repo" + "test": "./node_modules/mocha/bin/mocha ./test" }, "repository": { "type": "git", @@ -28,6 +28,7 @@ "chalk": "^1.1.1", "inquirer": "^0.12.0", "markdown2troff": "^0.1.0", + "npmi": "^2.0.1", "sanitize-filename": "^1.5.3", "tmp": "0.0.28", "yargs": "^3.32.0"