redis-memory-server
Version:
Redis Server for testing. The server will allow you to connect your favorite client library to the Redis Server and run parallel integration tests isolated from each other.
64 lines • 2.8 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const resolve_config_1 = __importDefault(require("./resolve-config"));
const debug_1 = __importDefault(require("debug"));
const RedisBinary_1 = require("./RedisBinary");
const log = (0, debug_1.default)('RedisMS:RedisBinaryDownloadUrl');
/**
* Download URL generator
*/
class RedisBinaryDownloadUrl {
constructor({ version }) {
this.version = version;
}
/**
* Assemble the URL to download
* Calls all the necessary functions to determine the URL
*/
getDownloadUrl() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const downloadUrl = (0, resolve_config_1.default)('DOWNLOAD_URL');
if (downloadUrl) {
log(`Using "${downloadUrl}" as the Download-URL`);
return downloadUrl;
}
if (process.platform === 'win32') {
return 'https://raw.githubusercontent.com/ServiceStack/redis-windows/master/downloads/redis-latest.zip';
}
const archive = yield this.getArchiveName();
log(`Using "${archive}" as the Archive String`);
const mirror = (_a = (0, resolve_config_1.default)('DOWNLOAD_MIRROR')) !== null && _a !== void 0 ? _a : 'https://download.redis.io';
log(`Using "${mirror}" as the mirror`);
return this.version === RedisBinary_1.LATEST_VERSION
? `${mirror}/${archive}`
: `${mirror}/releases/${archive}`;
});
}
/**
* Get the archive
* Version independent
*/
getArchiveName() {
return __awaiter(this, void 0, void 0, function* () {
if (process.platform === 'win32') {
return 'redis-latest.zip';
}
return `redis-${this.version}.tar.gz`;
});
}
}
exports.default = RedisBinaryDownloadUrl;
//# sourceMappingURL=RedisBinaryDownloadUrl.js.map