Skip to content

Commit

Permalink
Все, что можно убираем в asar, дляизбежания проблем с путями
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin committed May 28, 2017
1 parent 69c20f0 commit d44235f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "electron .",
"install": "electron-rebuild",
"build": "electron-rebuild --arch=ia32 && electron-packager ./ autoflash --platform=win32 --arch=ia32 --icon=../autoflash.ico --out=../ && electron-rebuild"
"build": "electron-rebuild --arch=ia32 && electron-packager ./ autoflash --platform=win32 --arch=ia32 --icon=../autoflash.ico --out=../ --asar.unpack=\"{*.exe,*.bin}\" && electron-rebuild"
},
"repository": "https://github.com/ilya-fedin/autoflash",
"author": "ilya-fedin",
Expand Down
23 changes: 18 additions & 5 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ var wmi = require('node-wmi');
var $ = require('jQuery');
require('bootstrap');

function _ajaxReadFile(src, callback) {
$.ajax({
url: src,
dataType: 'text',
success: function(data, textStatus, jqXHR) {
if(typeof(callback) == 'function') callback(data, textStatus, jqXHR);
}
});
}

function _addScript(src, callback) {
$.ajax({
url: src,
dataType: 'script',
success: function() {
success: function(data, textStatus, jqXHR) {
if(typeof(callback) == 'function') callback();
}
});
Expand Down Expand Up @@ -198,11 +208,11 @@ function detect(callback) {
else hilink_ip = '';
if(hilink_ip) {
$('body > div.container').append('<p>' + DIALOG_TRY_OPEN_PORT + '</p>');
fs.readFile('sw_project_mode.xml', function(err,data) {
_ajaxReadFile('sw_project_mode.xml', function(data, textStatus, jqXHR) {
$.ajax({
type: "POST",
url: 'http://' + hilink_ip + '/CGI',
data: data.toString()
data: data
});
});
}
Expand Down Expand Up @@ -752,7 +762,7 @@ function codes() {
}

function functions() {
fs.readFile('functions.' + LANG + '.txt', function(err, data) {
_ajaxReadFile('functions.' + LANG + '.txt', function(data, textStatus, jqXHR) {
$('body > div.container').append('<pre style="height: ' + ($(window).height() - 40) + 'px;">' + data + '</pre>');
$('body > div.container').append('<br>');
});
Expand Down Expand Up @@ -919,7 +929,10 @@ function main() {
});
}

process.chdir(__dirname);
if(/.asar$/.test(__dirname))
process.chdir(__dirname + '.unpacked');
else
process.chdir(__dirname);

if(path.basename(remote.process.argv[0]) == 'autoflash.exe') {
agr_mode = remote.process.argv[1];
Expand Down

0 comments on commit d44235f

Please sign in to comment.