handbrake-ts
Version:
Handbrake with TypeScript and support for electron
42 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const Errors_1 = require("./Errors");
const Node_1 = require("./Node");
class Config {
constructor() {
this.supportedPlatforms = ['darwin', 'linux', 'win32'];
this.mainDirectory = __dirname;
this.autoStart = false;
this.autoInstall = false;
this.id = Math.random();
}
get cli() {
return {
darwin: "HandBrakeCLI",
linux: "HandBrakeCLI",
win32: Node_1.path.join(this.mainDirectory, 'HandBrakeCLI.exe'),
};
}
getCliPath(dist) {
var _a;
const platform = dist !== null && dist !== void 0 ? dist : this.detectDist();
return (_a = this.cli[platform]) !== null && _a !== void 0 ? _a : null;
}
setCliPath(path, dist) {
const platform = dist !== null && dist !== void 0 ? dist : this.detectDist();
return this.cli[platform] = path;
}
detectDist() {
const platform = process.platform;
if (!this.supportedPlatforms.includes(platform))
throw new Errors_1.ErrorHB(platform, 'PLATFORM_NOT_SUPPORTED');
return platform;
}
static instance() {
return Config.singleton =
Config.singleton == null ? new Config() : Config.singleton;
}
}
exports.Config = Config;
//# sourceMappingURL=Config.js.map