mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-11 10:09:59 +00:00
Install scripts, build app with rollup & configurable mirror app id
This commit is contained in:
69
app/scripts/install-manifest.js
Normal file
69
app/scripts/install-manifest.js
Normal file
@@ -0,0 +1,69 @@
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const mkdirpSync = require('mkdirp').sync;
|
||||
|
||||
const MANIFEST_NAME = 'fx_cast_bridge.json';
|
||||
const MANIFEST_PATH = path.resolve(__dirname, '../../dist/app', MANIFEST_NAME);
|
||||
|
||||
const WIN_REGISTRY_KEY = 'fx_cast_bridge';
|
||||
|
||||
let destination = argv.destination;
|
||||
|
||||
switch (os.type()) {
|
||||
case 'Darwin': {
|
||||
if (!destination) {
|
||||
const root = argv.root || process.env.HOME;
|
||||
destination = path.resolve(
|
||||
path.join(
|
||||
root
|
||||
, 'Library/Application Support/Mozilla/NativeMessagingHosts'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Linux': {
|
||||
if (!destination) {
|
||||
const root = argv.root || `${process.env.HOME}/.`;
|
||||
destination = root.endsWith('/.')
|
||||
? `${root}mozilla/native-messaging-hosts/`
|
||||
: path.join(root, 'mozilla/native-messaging-hosts/');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Windows_NT': {
|
||||
const regedit = require('regedit');
|
||||
const destinationManifestPath = path.join(destination, MANIFEST_NAME)
|
||||
|| MANIFEST_PATH;
|
||||
|
||||
regedit.putValue({
|
||||
'HKEY_CURRENT_USER\\SOFTWARE\\Mozilla\\NativeMessagingHosts': {
|
||||
[WIN_REGISTRY_KEY]: {
|
||||
value: destinationManifestPath
|
||||
, type: 'REG_DEFAULT'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
console.error('Sorry, this installer does not yet support your OS');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (destination) {
|
||||
mkdirpSync(destination);
|
||||
fs.copyFileSync(
|
||||
MANIFEST_PATH
|
||||
, path.join(destination, MANIFEST_NAME)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user