add.[ALL]
This commit is contained in:
parent
5ac24c8cea
commit
780ad9a200
54 changed files with 3733 additions and 0 deletions
21
.resources/app/app_bootstrap/autoStart/darwin.js
Normal file
21
.resources/app/app_bootstrap/autoStart/darwin.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.install = install;
|
||||
exports.isInstalled = isInstalled;
|
||||
exports.uninstall = uninstall;
|
||||
exports.update = update;
|
||||
function install(callback) {
|
||||
return callback();
|
||||
}
|
||||
function update(callback) {
|
||||
return callback();
|
||||
}
|
||||
function isInstalled(callback) {
|
||||
return callback(false);
|
||||
}
|
||||
function uninstall(callback) {
|
||||
return callback();
|
||||
}
|
3
.resources/app/app_bootstrap/autoStart/index.js
Normal file
3
.resources/app/app_bootstrap/autoStart/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = require('./' + process.platform);
|
71
.resources/app/app_bootstrap/autoStart/linux.js
Normal file
71
.resources/app/app_bootstrap/autoStart/linux.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.install = install;
|
||||
exports.isInstalled = isInstalled;
|
||||
exports.uninstall = uninstall;
|
||||
exports.update = update;
|
||||
var _fs = _interopRequireDefault(require("fs"));
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
var _electron = require("electron");
|
||||
var _buildInfo = _interopRequireDefault(require("../buildInfo"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
// TODO: We should use Constant's APP_NAME, but only once
|
||||
// we set up backwards compat with this.
|
||||
const appName = _path.default.basename(process.execPath, '.exe');
|
||||
const exePath = _electron.app.getPath('exe');
|
||||
const exeDir = _path.default.dirname(exePath);
|
||||
const iconPath = _path.default.join(exeDir, 'discord.png');
|
||||
const autostartDir = _path.default.join(_electron.app.getPath('appData'), 'autostart');
|
||||
const electronAppName = _electron.app.name ? _electron.app.name : _electron.app.getName();
|
||||
const autostartFileName = _path.default.join(autostartDir, electronAppName + '-' + _buildInfo.default.releaseChannel + '.desktop');
|
||||
const desktopFile = `[Desktop Entry]
|
||||
Type=Application
|
||||
Exec=${exePath}
|
||||
Hidden=false
|
||||
NoDisplay=false
|
||||
Name=${appName}
|
||||
Icon=${iconPath}
|
||||
Comment=Text and voice chat for gamers.
|
||||
X-GNOME-Autostart-enabled=true
|
||||
`;
|
||||
function ensureDir() {
|
||||
try {
|
||||
_fs.default.mkdirSync(autostartDir);
|
||||
return true;
|
||||
} catch (e) {
|
||||
// catch for when it already exists.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function install(callback) {
|
||||
// TODO: This could fail. We should read its return value
|
||||
ensureDir();
|
||||
try {
|
||||
return _fs.default.writeFile(autostartFileName, desktopFile, callback);
|
||||
} catch (e) {
|
||||
// I guess we don't autostart then
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
function update(callback) {
|
||||
// TODO: We might need to implement this later on
|
||||
return callback();
|
||||
}
|
||||
function isInstalled(callback) {
|
||||
try {
|
||||
_fs.default.stat(autostartFileName, (err, stats) => {
|
||||
if (err) {
|
||||
return callback(false);
|
||||
}
|
||||
return callback(stats.isFile());
|
||||
});
|
||||
} catch (e) {
|
||||
return callback(false);
|
||||
}
|
||||
}
|
||||
function uninstall(callback) {
|
||||
return _fs.default.unlink(autostartFileName, callback);
|
||||
}
|
55
.resources/app/app_bootstrap/autoStart/win32.js
Normal file
55
.resources/app/app_bootstrap/autoStart/win32.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.install = install;
|
||||
exports.isInstalled = isInstalled;
|
||||
exports.uninstall = uninstall;
|
||||
exports.update = update;
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
var windowsUtils = _interopRequireWildcard(require("../windowsUtils"));
|
||||
var _appSettings = require("../appSettings");
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
const settings = (0, _appSettings.getSettings)();
|
||||
|
||||
// TODO: We should use Constant's APP_NAME, but only once
|
||||
// we set up backwards compat with this.
|
||||
const appName = _path.default.basename(process.execPath, '.exe');
|
||||
const fullExeName = _path.default.basename(process.execPath);
|
||||
const updatePath = _path.default.join(_path.default.dirname(process.execPath), '..', 'Update.exe');
|
||||
function install(callback) {
|
||||
const startMinimized = settings.get('START_MINIMIZED', false);
|
||||
let execPath = `"${updatePath}" --processStart ${fullExeName}`;
|
||||
if (startMinimized) {
|
||||
execPath = `${execPath} --process-start-args --start-minimized`;
|
||||
}
|
||||
const queue = [['HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run', '/v', appName, '/d', execPath]];
|
||||
windowsUtils.addToRegistry(queue, callback);
|
||||
}
|
||||
function update(callback) {
|
||||
isInstalled(installed => {
|
||||
if (installed) {
|
||||
install(callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
function isInstalled(callback) {
|
||||
const queryValue = ['HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run', '/v', appName];
|
||||
queryValue.unshift('query');
|
||||
windowsUtils.spawnReg(queryValue, (error, stdout) => {
|
||||
const doesOldKeyExist = stdout.indexOf(appName) >= 0;
|
||||
callback(doesOldKeyExist);
|
||||
});
|
||||
}
|
||||
function uninstall(callback) {
|
||||
const queryValue = ['HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run', '/v', appName, '/f'];
|
||||
queryValue.unshift('delete');
|
||||
windowsUtils.spawnReg(queryValue, (error, stdout) => {
|
||||
callback();
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue