Skip to content

Instantly share code, notes, and snippets.

@mojoaxel
Last active March 14, 2018 21:42
Show Gist options
  • Save mojoaxel/4663b9cc673767c198b6a82f407f1a8f to your computer and use it in GitHub Desktop.
Save mojoaxel/4663b9cc673767c198b6a82f407f1a8f to your computer and use it in GitHub Desktop.
install the latest debian version of zeit/hyper - download, npm install, npm start
{
"name": "hyper-updater",
"version": "1.0.0",
"description": "node.js script to install the latest version of zeit/hyper using the debian package",
"main": "update.js",
"scripts": {
"start": "npm run update",
"update": "node update.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alexander Wunschik <dev@wunschik.net>",
"license": "GPL-3.0",
"dependencies": {
"download": "^6.2.5",
"github": "^11.0.0",
"prettyjson": "^1.2.1",
"rimraf": "^2.6.2",
"sudo": "^1.0.3",
"temp-dir": "^1.0.0",
"underscore": "^1.8.3"
}
}
const GitHubApi = require("github");
const prettyjson = require('prettyjson');
const _ = require('underscore');
var download = require('download');;
const tempDir = require('temp-dir');
const path = require('path');
var sudo = require('sudo');
var rimfaf = require('rimraf');
var github = new GitHubApi();
github.repos.getReleases({
owner: 'zeit',
repo: 'hyper',
page: 1,
per_page: 1
}, function(err, res) {
var debianAsset = _.filter(res.data[0].assets, function(entry) {
return entry.name.endsWith('.deb');
})[0];
var filePath = path.join(tempDir, debianAsset.name);
console.log('Starting download of file: ' + filePath);
download(debianAsset.browser_download_url, tempDir).then(() => {
console.log('Downloaded finished!');
var options = {
cachePassword: true,
prompt: '*** sudo Password: '
};
console.log("Starting installation...");
var child = sudo([ 'dpkg', '-i', filePath ], options);
child.stdout.on('end', function (data) {
console.log("Installed finished");
rimfaf(filePath, () => {
console.log("removed tmp file");
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment