From f8e9c80fe814bf4a399207d5ce0ec94ba0e5c5e6 Mon Sep 17 00:00:00 2001 From: Adam Lynch Date: Thu, 21 Aug 2014 19:22:42 +0100 Subject: [PATCH] Small improvements to runInstaller - Removed `cb` parameter as it's not used & misleading. - `options` is now optional - Improved docs for `runInstaller` a bit. Still needs more work though. --- README.md | 6 +++++- app/updater.js | 17 +++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 986ca77..ead069f 100644 --- a/README.md +++ b/README.md @@ -90,10 +90,14 @@ Will unpack the `filename` in temporary folder. Callback arguments: error, unpacked directory -### updater:runInstaller(appPath, args, options) +### updater:runInstaller(apppath, args, options) Runs installer +`apppath` - String +`args` - Array of arguments which will be passed when running the new app +`options` - Optional object + ### updater:getAppPath() Returns executed application path diff --git a/app/updater.js b/app/updater.js index e7f480b..2d4ece6 100644 --- a/app/updater.js +++ b/app/updater.js @@ -8,7 +8,7 @@ // checkNewVersion(cb) - checks new version of app // download(cb) - downloads new version in temp // unpack(cb) - unpacks the version - // runInstaller(cb) - is starting the installer + // runInstaller(apppath, args, options) - is starting the installer // -------INSTALLER--- // install(cb) - installs the app in app folder // runApp(cb) - starting the app @@ -20,7 +20,7 @@ var execFile = require('child_process').execFile; var spawn = require('child_process').spawn; var ncp = require('ncp'); - + var platform = /^win/.test(process.platform)?'win':/^darwin/.test(process.platform)?'mac':process.arch == 'ia32'?'linux32':'linux64'; //here will be regular exp where we will define platform function updater(manifest){ @@ -58,7 +58,7 @@ fs.unlink(path.join(os.tmpdir(), filename), function(){ pkg.pipe(fs.createWriteStream(path.join(os.tmpdir(), filename))); }); - + pkg.on('end', appDownloaded); function appDownloaded(){ @@ -180,20 +180,21 @@ } return run('open', args, options); }, - win: function(apppath, args, options, cb){ - return run(apppath, args, options, cb); + win: function(apppath, args, options){ + return run(apppath, args, options); }, - linux32: function(apppath, args, options, cb){ + linux32: function(apppath, args, options){ fs.chmodSync(apppath, 0755); if(!options) options = {}; options.cwd = path.dirname(apppath); - return run(apppath, args, options, cb); + return run(apppath, args, options); } } pRun.linux64 = pRun.linux32; - function run(path, args, options, cb){ + function run(path, args, options){ + if(!options) options = {}; var opts = { detached: true }