Skip to content

Commit

Permalink
1. Removing sudo requirement for Linux and Mac. 2. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-portmen committed Feb 13, 2017
1 parent 1b48389 commit 8561e85
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 17 deletions.
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ exports.ids = {
'{0ff128a1-c286-4e73-bffa-9ae879b244d5}', // Media Converter
'{65b77238-bb05-470a-a445-ec0efe1d66c4}', // External Application Button
'{086f665e-6a55-4107-9147-f9a14e72b137}', // Open in Chrome
'73abcedca60bc2c834a15eb8ff956ce8593cec9f@temporary-addon', // TEST
]
};
2 changes: 1 addition & 1 deletion host.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var https = lazyRequire('./follow-redirects').https;
var server, files = [];

var config = {
version: '0.2.6'
version: '0.2.7'
};
// closing node when parent process is killed
process.stdin.resume();
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ cd ./app

if type node 2>/dev/null; then
echo "Installer is using your system NodeJS; Please make sure your NodeJS is up-to-date."
sudo node install.js `which node` $1
node install.js `which node` $1
else
echo "Installer is using the attached NodeJS"
sudo ../node install.js --add_node $1
../node install.js --add_node $1
fi

2 changes: 0 additions & 2 deletions linux/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
To install the native application
1. Open a terminal window and point it into this directory
2. run ./install.sh

Note: The script needs administrator permission (sudo) to copy files successfully.
31 changes: 26 additions & 5 deletions linux/app/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var fs = require('fs');
var path = require('path');

var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || '/usr/share';
var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || process.env.HOME;
if (share[0] === '~') {
share = path.join(process.env.HOME, share.slice(1));
}
Expand Down Expand Up @@ -102,25 +102,46 @@ function application (callback) {
}
function chrome (callback) {
if (ids.chrome.length) {
manifest('/etc/opt/chrome/native-messaging-hosts', 'chrome', callback);
let loc = path.join(
process.env.HOME,
'.config/google-chrome/NativeMessagingHosts'
);
manifest(loc, 'chrome', callback);
console.error(' -> Chrome Browser is supported');
}
else {
callback();
}
}
function chromium (callback) {
if (ids.chrome.length) {
let loc = path.join(
process.env.HOME,
'.config/chromium/NativeMessagingHosts'
);
manifest(loc, 'chrome', callback);
console.error(' -> Chromium Browser is supported');
}
else {
callback();
}
}
function firefox (callback) {
if (ids.firefox.length) {
manifest('/usr/lib/mozilla/native-messaging-hosts', 'firefox', callback);
let loc = path.join(
process.env.HOME,
'.mozilla/native-messaging-hosts'
);
manifest(loc, 'firefox', callback);
console.error(' -> Firefox Browser is supported');
}
else {
callback();
}
}
chrome(() => firefox(() => {
chrome(() => chromium(() => firefox(() => {
application(() => {
console.error(' => Native Host is installed in', dir);
console.error('\n\n>>> Application is ready to use <<<\n\n');
});
}));
})));
2 changes: 0 additions & 2 deletions mac/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
To install the native application
1. Open a terminal window and point it into this directory
2. run ./install.sh

Note: The script needs administrator permission (sudo) to copy files successfully.
31 changes: 26 additions & 5 deletions mac/app/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var fs = require('fs');
var path = require('path');

var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || '/usr/share';
var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || process.env.HOME;
if (share[0] === '~') {
share = path.join(process.env.HOME, share.slice(1));
}
Expand Down Expand Up @@ -107,25 +107,46 @@ function application (callback) {

function chrome (callback) {
if (ids.chrome.length) {
manifest('/Library/Google/Chrome/NativeMessagingHosts', 'chrome', callback);
let loc = path.join(
process.env.HOME,
'Library/Application Support/Google/Chrome/NativeMessagingHosts'
);
manifest(loc, 'chrome', callback);
console.error(' -> Chrome Browser is supported');
}
else {
callback();
}
}
function chromium (callback) {
if (ids.chrome.length) {
let loc = path.join(
process.env.HOME,
'Library/Application Support/Chromium/NativeMessagingHosts'
);
manifest(loc, 'chrome', callback);
console.error(' -> Chromium Browser is supported');
}
else {
callback();
}
}
function firefox (callback) {
if (ids.firefox.length) {
manifest('/Library/Application Support/Mozilla/NativeMessagingHosts', 'firefox', callback);
let loc = path.join(
process.env.HOME,
'Library/Application Support/Mozilla/NativeMessagingHosts'
);
manifest(loc, 'firefox', callback);
console.error(' -> Firefox Browser is supported');
}
else {
callback();
}
}
chrome(() => firefox(() => {
chrome(() => chromium(() => firefox(() => {
application(() => {
console.error(' -> Native Host is installed in', dir);
console.error('\n\n>>> Application is ready to use <<<\n\n');
});
}));
})));

0 comments on commit 8561e85

Please sign in to comment.