@@ -39,11 +39,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3939 });
4040};
4141Object.defineProperty(exports, "__esModule", ({ value: true }));
42- const fs_1 = __nccwpck_require__(7147);
43- const glob_1 = __nccwpck_require__(5029);
4442const path_1 = __nccwpck_require__(1017);
4543const executeCommand_1 = __nccwpck_require__(3285);
4644const log_1 = __importStar(__nccwpck_require__(1285));
45+ const locateArchiveFile_1 = __nccwpck_require__(1767);
4746function applyCommand(command) {
4847 return __awaiter(this, void 0, void 0, function* () {
4948 if (!command)
@@ -67,14 +66,7 @@ class Archiver {
6766 if (revision)
6867 archiveCommand += ` --revision ${revision}`;
6968 yield (0, executeCommand_1.executeCommand)(archiveCommand);
70- const archiveFiles = (yield (0, glob_1.glob)((0, path_1.join)('.appmap', 'archive', '**', '*.tar'), { dot: true })).filter(file => (0, fs_1.existsSync)(file));
71- if (archiveFiles.length === 0) {
72- throw new Error(`No AppMap archives found in ${process.cwd()}`);
73- }
74- if (archiveFiles.length > 1) {
75- (0, log_1.default)(log_1.LogLevel.Warn, `Multiple AppMap archives found in ${process.cwd()}`);
76- }
77- const archiveFile = archiveFiles.pop();
69+ const archiveFile = yield (0, locateArchiveFile_1.locateArchiveFile)('.');
7870 (0, log_1.default)(log_1.LogLevel.Debug, `Processing AppMap archive ${archiveFile}`);
7971 // e.g. .appmap/archive/full
8072 const dir = (0, path_1.dirname)(archiveFile);
@@ -171,8 +163,10 @@ function executeCommand(cmd, printCommand = (0, verbose_1.default)(), printStdou
171163 });
172164 }
173165 return new Promise((resolve, reject) => {
174- command.addListener('exit', code => {
175- if (code === 0) {
166+ command.addListener('exit', (code, signal) => {
167+ if (signal || code === 0) {
168+ if (signal)
169+ (0, log_1.default)(log_1.LogLevel.Info, `Command killed by signal ${signal}`);
176170 resolve(result.join(''));
177171 }
178172 else {
@@ -259,6 +253,70 @@ if (require.main === require.cache[eval('__filename')]) {
259253}
260254
261255
256+ /***/ }),
257+
258+ /***/ 1767:
259+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
260+
261+ "use strict";
262+
263+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
264+ if (k2 === undefined) k2 = k;
265+ var desc = Object.getOwnPropertyDescriptor(m, k);
266+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
267+ desc = { enumerable: true, get: function() { return m[k]; } };
268+ }
269+ Object.defineProperty(o, k2, desc);
270+ }) : (function(o, m, k, k2) {
271+ if (k2 === undefined) k2 = k;
272+ o[k2] = m[k];
273+ }));
274+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
275+ Object.defineProperty(o, "default", { enumerable: true, value: v });
276+ }) : function(o, v) {
277+ o["default"] = v;
278+ });
279+ var __importStar = (this && this.__importStar) || function (mod) {
280+ if (mod && mod.__esModule) return mod;
281+ var result = {};
282+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
283+ __setModuleDefault(result, mod);
284+ return result;
285+ };
286+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
287+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
288+ return new (P || (P = Promise))(function (resolve, reject) {
289+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
290+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
291+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
292+ step((generator = generator.apply(thisArg, _arguments || [])).next());
293+ });
294+ };
295+ Object.defineProperty(exports, "__esModule", ({ value: true }));
296+ exports.locateArchiveFile = void 0;
297+ const fs_1 = __nccwpck_require__(7147);
298+ const glob_1 = __nccwpck_require__(5029);
299+ const path_1 = __nccwpck_require__(1017);
300+ const log_1 = __importStar(__nccwpck_require__(1285));
301+ const promises_1 = __nccwpck_require__(3292);
302+ function locateArchiveFile(workDir) {
303+ return __awaiter(this, void 0, void 0, function* () {
304+ const archiveFiles = (yield (0, glob_1.glob)((0, path_1.join)(workDir, '.appmap', 'archive', '**', '*.tar'), { dot: true })).filter(file => (0, fs_1.existsSync)(file));
305+ const archiveFileTimes = new Map();
306+ yield Promise.all(archiveFiles.map((file) => __awaiter(this, void 0, void 0, function* () { return archiveFileTimes.set(file, (yield (0, promises_1.stat)(file)).mtimeMs); })));
307+ archiveFiles.sort((a, b) => archiveFileTimes.get(b) - archiveFileTimes.get(a));
308+ if (archiveFiles.length === 0)
309+ throw new Error(`No AppMap archives found in ${(0, path_1.join)(process.cwd(), workDir)}`);
310+ const result = archiveFiles.shift();
311+ if (archiveFiles.length > 1) {
312+ (0, log_1.default)(log_1.LogLevel.Warn, `Multiple AppMap archives found in ${(0, path_1.join)(process.cwd(), workDir)}.\nI'll upload the most recent one, which is ${result}.`);
313+ }
314+ return result;
315+ });
316+ }
317+ exports.locateArchiveFile = locateArchiveFile;
318+
319+
262320/***/ }),
263321
264322/***/ 1285:
0 commit comments