redis-memory-server 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/bin/index.js +21 -0
- package/lib/RedisMemoryServer.js +126 -212
- package/lib/RedisMemoryServer.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +5 -5
- package/lib/types.d.ts.map +1 -1
- package/lib/util/RedisBinary.js +123 -205
- package/lib/util/RedisBinary.js.map +1 -1
- package/lib/util/RedisBinaryDownload.d.ts +1 -1
- package/lib/util/RedisBinaryDownload.d.ts.map +1 -1
- package/lib/util/RedisBinaryDownload.js +201 -333
- package/lib/util/RedisBinaryDownload.js.map +1 -1
- package/lib/util/RedisBinaryDownloadUrl.js +32 -71
- package/lib/util/RedisBinaryDownloadUrl.js.map +1 -1
- package/lib/util/RedisInstance.d.ts +1 -0
- package/lib/util/RedisInstance.d.ts.map +1 -1
- package/lib/util/RedisInstance.js +126 -202
- package/lib/util/RedisInstance.js.map +1 -1
- package/lib/util/resolve-config.js +20 -22
- package/lib/util/resolve-config.js.map +1 -1
- package/package.json +45 -49
- package/scripts/postinstall.js +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Marc Hassan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -95,6 +95,14 @@ redisServer.getInstanceInfo();
|
|
|
95
95
|
// when your script exits, a special process killer will shut it down for you
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
### Start server via npx
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx redis-memory-server
|
|
102
|
+
# OR
|
|
103
|
+
REDISMS_PORT=6379 npx redis-memory-server
|
|
104
|
+
```
|
|
105
|
+
|
|
98
106
|
### Available options for RedisMemoryServer
|
|
99
107
|
|
|
100
108
|
All settings are optional.
|
|
@@ -177,6 +185,7 @@ or
|
|
|
177
185
|
}
|
|
178
186
|
```
|
|
179
187
|
|
|
188
|
+
|
|
180
189
|
## Credits
|
|
181
190
|
|
|
182
191
|
This package is inspired heavily by [mongodb-memory-server](https://npmjs.com/package/mongodb-memory-server).
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint @typescript-eslint/no-var-requires: 0 */
|
|
4
|
+
|
|
5
|
+
const RedisMemoryServer = require('../lib/index.js').default;
|
|
6
|
+
|
|
7
|
+
(async () => {
|
|
8
|
+
const server = new RedisMemoryServer({
|
|
9
|
+
instance: {
|
|
10
|
+
port: process.env.REDISMS_PORT ? parseInt(process.env.REDISMS_PORT, 10) : undefined,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const host = await server.getHost();
|
|
15
|
+
const port = await server.getPort();
|
|
16
|
+
|
|
17
|
+
console.log(`Redis server running at: ${host}:${port}`);
|
|
18
|
+
})().catch((error) => {
|
|
19
|
+
console.error(error);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
package/lib/RedisMemoryServer.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
16
9
|
}) : (function(o, m, k, k2) {
|
|
17
10
|
if (k2 === undefined) k2 = k;
|
|
18
11
|
o[k2] = m[k];
|
|
@@ -38,55 +31,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
38
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
32
|
});
|
|
40
33
|
};
|
|
41
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
42
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
43
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
44
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
|
-
function step(op) {
|
|
46
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
-
while (_) try {
|
|
48
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
49
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
|
-
switch (op[0]) {
|
|
51
|
-
case 0: case 1: t = op; break;
|
|
52
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
53
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
54
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
55
|
-
default:
|
|
56
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
57
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
58
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
59
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
60
|
-
if (t[2]) _.ops.pop();
|
|
61
|
-
_.trys.pop(); continue;
|
|
62
|
-
}
|
|
63
|
-
op = body.call(thisArg, _);
|
|
64
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
65
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
69
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
70
36
|
};
|
|
71
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
38
|
+
const tmp = __importStar(require("tmp"));
|
|
39
|
+
const get_port_1 = __importDefault(require("get-port"));
|
|
40
|
+
const db_util_1 = require("./util/db_util");
|
|
41
|
+
const RedisInstance_1 = __importDefault(require("./util/RedisInstance"));
|
|
42
|
+
const debug_1 = __importDefault(require("debug"));
|
|
43
|
+
const log = (0, debug_1.default)('RedisMS:RedisMemoryServer');
|
|
78
44
|
tmp.setGracefulCleanup();
|
|
79
|
-
|
|
45
|
+
class RedisMemoryServer {
|
|
80
46
|
/**
|
|
81
47
|
* Create an Redis-Memory-Sever Instance
|
|
82
48
|
*
|
|
83
49
|
* Note: because of JavaScript limitations, autoStart cannot be awaited here, use ".create" for async/await ability
|
|
84
50
|
* @param opts Redis-Memory-Sever Options
|
|
85
51
|
*/
|
|
86
|
-
|
|
52
|
+
constructor(opts) {
|
|
87
53
|
this.runningInstance = null;
|
|
88
54
|
this.instanceInfoSync = null;
|
|
89
|
-
this.opts =
|
|
55
|
+
this.opts = Object.assign({}, opts);
|
|
90
56
|
if ((opts === null || opts === void 0 ? void 0 : opts.autoStart) === true) {
|
|
91
57
|
log('Autostarting Redis instance...');
|
|
92
58
|
this.start();
|
|
@@ -96,211 +62,159 @@ var RedisMemoryServer = /** @class */ (function () {
|
|
|
96
62
|
* Create an Redis-Memory-Sever Instance that can be awaited
|
|
97
63
|
* @param opts Redis-Memory-Sever Options
|
|
98
64
|
*/
|
|
99
|
-
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return [4 /*yield*/, instance.start()];
|
|
108
|
-
case 1:
|
|
109
|
-
_a.sent();
|
|
110
|
-
_a.label = 2;
|
|
111
|
-
case 2: return [2 /*return*/, instance];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
65
|
+
static create(opts) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
// create an instance WITHOUT autoStart so that the user can await it
|
|
68
|
+
const instance = new RedisMemoryServer(Object.assign(Object.assign({}, opts), { autoStart: false }));
|
|
69
|
+
if (opts === null || opts === void 0 ? void 0 : opts.autoStart) {
|
|
70
|
+
yield instance.start();
|
|
71
|
+
}
|
|
72
|
+
return instance;
|
|
114
73
|
});
|
|
115
|
-
}
|
|
74
|
+
}
|
|
116
75
|
/**
|
|
117
76
|
* Start the in-memory Instance
|
|
118
77
|
* (when options.autoStart is true, this already got called)
|
|
119
78
|
*/
|
|
120
|
-
|
|
121
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
if ((_a = _this.opts.instance) === null || _a === void 0 ? void 0 : _a.port) {
|
|
134
|
-
_this.opts.instance.port = null;
|
|
135
|
-
}
|
|
136
|
-
return _this._startUpInstance();
|
|
137
|
-
}
|
|
138
|
-
throw err;
|
|
139
|
-
})
|
|
140
|
-
.catch(function (err) {
|
|
141
|
-
if (!debug_1.default.enabled('RedisMS:RedisMemoryServer')) {
|
|
142
|
-
console.warn('Starting the instance failed, please enable debug for more infomation');
|
|
79
|
+
start() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
log('Called RedisMemoryServer.start() method');
|
|
82
|
+
if (this.runningInstance) {
|
|
83
|
+
throw new Error('Redis instance already in status startup/running/error. Use debug for more info.');
|
|
84
|
+
}
|
|
85
|
+
this.runningInstance = this._startUpInstance()
|
|
86
|
+
.catch((err) => {
|
|
87
|
+
var _a;
|
|
88
|
+
if (err.message === 'redis-server shutting down' || err === 'redis-server shutting down') {
|
|
89
|
+
log(`Redis did not start. Trying to start on another port one more time...`);
|
|
90
|
+
if ((_a = this.opts.instance) === null || _a === void 0 ? void 0 : _a.port) {
|
|
91
|
+
this.opts.instance.port = null;
|
|
143
92
|
}
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
93
|
+
return this._startUpInstance();
|
|
94
|
+
}
|
|
95
|
+
throw err;
|
|
96
|
+
})
|
|
97
|
+
.catch((err) => {
|
|
98
|
+
if (!debug_1.default.enabled('RedisMS:RedisMemoryServer')) {
|
|
99
|
+
console.warn('Starting the instance failed, please enable debug for more infomation');
|
|
100
|
+
}
|
|
101
|
+
throw err;
|
|
102
|
+
});
|
|
103
|
+
return this.runningInstance.then((data) => {
|
|
104
|
+
this.instanceInfoSync = data;
|
|
105
|
+
return true;
|
|
150
106
|
});
|
|
151
107
|
});
|
|
152
|
-
}
|
|
108
|
+
}
|
|
153
109
|
/**
|
|
154
110
|
* Internal Function to start an instance
|
|
155
111
|
* @private
|
|
156
112
|
*/
|
|
157
|
-
|
|
113
|
+
_startUpInstance() {
|
|
158
114
|
var _a, _b, _c, _d;
|
|
159
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
args: instOpts.args,
|
|
182
|
-
},
|
|
183
|
-
binary: this.opts.binary,
|
|
184
|
-
spawn: this.opts.spawn,
|
|
185
|
-
})];
|
|
186
|
-
case 2:
|
|
187
|
-
instance = _f.sent();
|
|
188
|
-
return [2 /*return*/, __assign(__assign({}, data), { instance: instance, childProcess: (_d = instance.childProcess) !== null && _d !== void 0 ? _d : undefined })];
|
|
189
|
-
}
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
/** Shortcut to this.opts.instance */
|
|
117
|
+
const instOpts = (_a = this.opts.instance) !== null && _a !== void 0 ? _a : {};
|
|
118
|
+
const data = {
|
|
119
|
+
port: yield (0, get_port_1.default)({ port: (_b = instOpts.port) !== null && _b !== void 0 ? _b : undefined }),
|
|
120
|
+
ip: (_c = instOpts.ip) !== null && _c !== void 0 ? _c : '127.0.0.1',
|
|
121
|
+
tmpDir: undefined,
|
|
122
|
+
};
|
|
123
|
+
if (instOpts.port != data.port) {
|
|
124
|
+
log(`starting with port ${data.port}, since ${instOpts.port} was locked:`, data.port);
|
|
125
|
+
}
|
|
126
|
+
log(`Starting Redis instance with following options: ${JSON.stringify(data)}`);
|
|
127
|
+
// Download if not exists redis binaries in ~/.redis-prebuilt
|
|
128
|
+
// After that startup Redis instance
|
|
129
|
+
const instance = yield RedisInstance_1.default.run({
|
|
130
|
+
instance: {
|
|
131
|
+
ip: data.ip,
|
|
132
|
+
port: data.port,
|
|
133
|
+
args: instOpts.args,
|
|
134
|
+
},
|
|
135
|
+
binary: this.opts.binary,
|
|
136
|
+
spawn: this.opts.spawn,
|
|
190
137
|
});
|
|
138
|
+
return Object.assign(Object.assign({}, data), { instance: instance, childProcess: (_d = instance.childProcess) !== null && _d !== void 0 ? _d : undefined });
|
|
191
139
|
});
|
|
192
|
-
}
|
|
140
|
+
}
|
|
193
141
|
/**
|
|
194
142
|
* Stop the current In-Memory Instance
|
|
195
143
|
*/
|
|
196
|
-
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
|
|
199
|
-
return
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
_b.sent();
|
|
215
|
-
this.runningInstance = null;
|
|
216
|
-
this.instanceInfoSync = null;
|
|
217
|
-
if (tmpDir) {
|
|
218
|
-
log("Removing tmpDir " + tmpDir.name);
|
|
219
|
-
tmpDir.removeCallback();
|
|
220
|
-
}
|
|
221
|
-
return [2 /*return*/, true];
|
|
222
|
-
}
|
|
223
|
-
});
|
|
144
|
+
stop() {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
log('Called RedisMemoryServer.stop() method');
|
|
147
|
+
// just return "true" if the instance is already running / defined
|
|
148
|
+
if ((0, db_util_1.isNullOrUndefined)(this.runningInstance)) {
|
|
149
|
+
log('Instance is already stopped, returning true');
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
const { instance, port, tmpDir } = yield this.ensureInstance();
|
|
153
|
+
log(`Shutdown Redis server on port ${port} with pid ${instance.getPid() || ''}`);
|
|
154
|
+
yield instance.kill();
|
|
155
|
+
this.runningInstance = null;
|
|
156
|
+
this.instanceInfoSync = null;
|
|
157
|
+
if (tmpDir) {
|
|
158
|
+
log(`Removing tmpDir ${tmpDir.name}`);
|
|
159
|
+
tmpDir.removeCallback();
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
224
162
|
});
|
|
225
|
-
}
|
|
163
|
+
}
|
|
226
164
|
/**
|
|
227
165
|
* Get Information about the currently running instance, if it is not running it returns "false"
|
|
228
166
|
*/
|
|
229
|
-
|
|
167
|
+
getInstanceInfo() {
|
|
230
168
|
var _a;
|
|
231
169
|
return (_a = this.instanceInfoSync) !== null && _a !== void 0 ? _a : false;
|
|
232
|
-
}
|
|
170
|
+
}
|
|
233
171
|
/**
|
|
234
172
|
* Ensure that the instance is running
|
|
235
173
|
* -> throws if instance cannot be started
|
|
236
174
|
*/
|
|
237
|
-
|
|
238
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// check again for 1. Typescript-type reasons and 2. if .start failed to throw an error
|
|
252
|
-
if (!this.runningInstance) {
|
|
253
|
-
throw new Error('Ensure-Instance failed to start an instance!');
|
|
254
|
-
}
|
|
255
|
-
return [2 /*return*/, this.runningInstance];
|
|
256
|
-
}
|
|
257
|
-
});
|
|
175
|
+
ensureInstance() {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
log('Called RedisMemoryServer.ensureInstance() method');
|
|
178
|
+
if (this.runningInstance) {
|
|
179
|
+
return this.runningInstance;
|
|
180
|
+
}
|
|
181
|
+
log(' - no running instance, call `start()` command');
|
|
182
|
+
yield this.start();
|
|
183
|
+
log(' - `start()` command was succesfully resolved');
|
|
184
|
+
// check again for 1. Typescript-type reasons and 2. if .start failed to throw an error
|
|
185
|
+
if (!this.runningInstance) {
|
|
186
|
+
throw new Error('Ensure-Instance failed to start an instance!');
|
|
187
|
+
}
|
|
188
|
+
return this.runningInstance;
|
|
258
189
|
});
|
|
259
|
-
}
|
|
190
|
+
}
|
|
260
191
|
/**
|
|
261
192
|
* Get a redis host
|
|
262
193
|
*/
|
|
263
|
-
|
|
264
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
265
|
-
return
|
|
266
|
-
return [2 /*return*/, this.getIp()];
|
|
267
|
-
});
|
|
194
|
+
getHost() {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
return this.getIp();
|
|
268
197
|
});
|
|
269
|
-
}
|
|
198
|
+
}
|
|
270
199
|
/**
|
|
271
200
|
* Get a redis IP
|
|
272
201
|
*/
|
|
273
|
-
|
|
274
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
275
|
-
|
|
276
|
-
return
|
|
277
|
-
switch (_a.label) {
|
|
278
|
-
case 0: return [4 /*yield*/, this.ensureInstance()];
|
|
279
|
-
case 1:
|
|
280
|
-
ip = (_a.sent()).ip;
|
|
281
|
-
return [2 /*return*/, ip];
|
|
282
|
-
}
|
|
283
|
-
});
|
|
202
|
+
getIp() {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
const { ip } = yield this.ensureInstance();
|
|
205
|
+
return ip;
|
|
284
206
|
});
|
|
285
|
-
}
|
|
207
|
+
}
|
|
286
208
|
/**
|
|
287
209
|
* Get the Port of the currently running Instance
|
|
288
210
|
* Note: calls "ensureInstance"
|
|
289
211
|
*/
|
|
290
|
-
|
|
291
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
292
|
-
|
|
293
|
-
return
|
|
294
|
-
switch (_a.label) {
|
|
295
|
-
case 0: return [4 /*yield*/, this.ensureInstance()];
|
|
296
|
-
case 1:
|
|
297
|
-
port = (_a.sent()).port;
|
|
298
|
-
return [2 /*return*/, port];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
212
|
+
getPort() {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const { port } = yield this.ensureInstance();
|
|
215
|
+
return port;
|
|
301
216
|
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
}());
|
|
217
|
+
}
|
|
218
|
+
}
|
|
305
219
|
exports.default = RedisMemoryServer;
|
|
306
220
|
//# sourceMappingURL=RedisMemoryServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisMemoryServer.js","sourceRoot":"","sources":["../src/RedisMemoryServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RedisMemoryServer.js","sourceRoot":"","sources":["../src/RedisMemoryServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA2B;AAC3B,wDAA+B;AAC/B,4CAAmD;AACnD,yEAAiD;AAGjD,kDAA0B;AAE1B,MAAM,GAAG,GAAG,IAAA,eAAK,E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AAC,eAAe,EAAE;gBACxB,OAAO,IAAI,CAAC,eAAe,CAAC;aAC7B;YACD,GAAG,CAAC,gDAAgD,CAAC,CAAC;YACtD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,GAAG,CAAC,+CAA+C,CAAC,CAAC;YAErD,uFAAuF;YACvF,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;gBACzB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;aACjE;YAED,OAAO,IAAI,CAAC,eAAe,CAAC;QAC9B,CAAC;KAAA;IAED;;OAEG;IACG,OAAO;;YACX,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;KAAA;IAED;;OAEG;IACG,KAAK;;YACT,MAAM,EAAE,EAAE,EAAE,GAAuB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC/D,OAAO,EAAE,CAAC;QACZ,CAAC;KAAA;IAED;;;OAGG;IACG,OAAO;;YACX,MAAM,EAAE,IAAI,EAAE,GAAuB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF;AA9LD,oCA8LC"}
|
package/lib/index.js
CHANGED
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RedisMemoryServer = exports.RedisInstance = exports.RedisBinary = void 0;
|
|
7
7
|
require("./util/resolve-config"); // import it for the side-effects (globals)
|
|
8
|
-
|
|
8
|
+
const RedisBinary_1 = __importDefault(require("./util/RedisBinary"));
|
|
9
9
|
exports.RedisBinary = RedisBinary_1.default;
|
|
10
|
-
|
|
10
|
+
const RedisInstance_1 = __importDefault(require("./util/RedisInstance"));
|
|
11
11
|
exports.RedisInstance = RedisInstance_1.default;
|
|
12
|
-
|
|
12
|
+
const RedisMemoryServer_1 = __importDefault(require("./RedisMemoryServer"));
|
|
13
13
|
exports.RedisMemoryServer = RedisMemoryServer_1.default;
|
|
14
14
|
exports.default = RedisMemoryServer_1.default;
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAA+B,CAAC,2CAA2C;AAE3E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAA+B,CAAC,2CAA2C;AAE3E,qEAA6C;AAKpC,sBALF,qBAAW,CAKE;AAJpB,yEAAiD;AAI3B,wBAJf,uBAAa,CAIe;AAHnC,4EAAoD;AAGf,4BAH9B,2BAAiB,CAG8B;AADtD,kBAAe,2BAAiB,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type DebugFn = (...args: any[]) => any;
|
|
2
|
+
export type DebugPropT = boolean;
|
|
3
3
|
export interface DownloadProgressT {
|
|
4
4
|
current: number;
|
|
5
5
|
length: number;
|
|
6
6
|
totalMb: number;
|
|
7
7
|
lastPrintedAt: number;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type CallbackFn = (...args: any[]) => any;
|
|
10
10
|
export { SpawnOptions } from 'child_process';
|
|
11
11
|
export interface RedisMemoryInstancePropBaseT {
|
|
12
12
|
args?: string[];
|
|
@@ -15,6 +15,6 @@ export interface RedisMemoryInstancePropBaseT {
|
|
|
15
15
|
export interface RedisMemoryInstancePropT extends RedisMemoryInstancePropBaseT {
|
|
16
16
|
ip?: string;
|
|
17
17
|
}
|
|
18
|
-
export
|
|
19
|
-
export
|
|
18
|
+
export type ErrorVoidCallback = (err: any) => void;
|
|
19
|
+
export type EmptyVoidCallback = () => void;
|
|
20
20
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAC9C,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAEjC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,wBAAyB,SAAQ,4BAA4B;IAC5E,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC"}
|