Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node-webkit app- how to update it?

Tags:

node-webkit

I am using node-webkit to develop apps for my students, and to provide one stop solution I would need to update node-webkit archive once in a month. Is there a way I can accomplish that? Basically I need to replace just one html file every month, say "page1.html". I googled but have no idea where to start.

like image 512
swapna Avatar asked Aug 10 '26 22:08

swapna


2 Answers

On Mac, you can access the filesystem of the own app e.g.

$ ls -lh /Applications/Shock.app/Contents/Resources/app.nw/
[...]
-rw-r--r--  1 jordi  staff   2,3K 29 gen 01:47 index.html
-rw-r--r--  1 jordi  staff   467B 29 gen 01:47 lecturenotes.html
[...]

So if you put a new version on a specific URL, you could fetch it and rewrite the HTML file inside the app:

var request = require('request');
request('http://www.your-own-server.com/app/lecturenotes.html', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    var fs = require('fs');
    fs.writeFileSync('/Applications/Shock.app/Contents/Resources/app.nw/lecturenotes.html', body);
  }
});

I think something similar happens on Linux. Unfortunately, the Windows version works with a binary package into the exe, so this trick won't work for the last case.

like image 114
brickpop Avatar answered Aug 13 '26 12:08

brickpop


I have used App.dataPath as described in https://github.com/nwjs/nw.js/wiki/App

You can download the html files into that path. App.dataPath works platform independent , though the location is different based on the platforms , your app will have a generic path to refer the html files.

excerpt :

Get the application's data path in user's directory. Windows: %LOCALAPPDATA%/; Linux: ~/.config/; OSX: ~/Library/Application Support/ where is the field in the manifest.

like image 28
Tito Avatar answered Aug 13 '26 13:08

Tito



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!