@ts-dev-tools/core 1.12.1 → 1.12.2
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/dist/bin.js +26 -76
- package/dist/constants.js +2 -2
- package/dist/eslint-plugin-ts-dev-tools/index.js +18 -30
- package/dist/install/command.js +30 -80
- package/dist/install/migrations/20201024173398-init.js +89 -141
- package/dist/install/migrations/20220617100200-prettier-cache.js +9 -49
- package/dist/install/migrations/20240329200200-eslint-ignore.js +9 -49
- package/dist/install/migrations/20240412185500-eslint-config.js +16 -53
- package/dist/install/migrations/20240617094000-config-nx-scopes.js +22 -67
- package/dist/install/migrations/20250623095500-add-prettier-oxc.js +9 -49
- package/dist/install/migrations/20250623095600-remove-prettier-oxc.js +15 -55
- package/dist/services/CmdService.js +17 -21
- package/dist/services/CorePackageService.js +8 -11
- package/dist/services/DuplicateDependenciesService.js +28 -33
- package/dist/services/FileService.js +11 -14
- package/dist/services/GitService.js +36 -83
- package/dist/services/MigrationsService.js +52 -121
- package/dist/services/PackageJson.js +47 -57
- package/dist/services/PackageJsonMerge.js +17 -21
- package/dist/services/PackageManagerService.js +25 -80
- package/dist/services/PeerDependenciesService.js +92 -157
- package/dist/services/PluginService.js +32 -39
- package/dist/services/SymlinkDependenciesService.js +52 -133
- package/dist/services/package-manager/AbstractPackageManagerAdapter.js +84 -138
- package/dist/services/package-manager/NpmPackageManagerAdapter.js +58 -158
- package/dist/services/package-manager/YarnPackageManagerAdapter.js +122 -235
- package/dist/tests/cli.js +12 -57
- package/dist/tests/console.js +5 -6
- package/dist/tests/file-system.js +23 -92
- package/dist/tests/test-cache.js +5 -5
- package/dist/tests/test-packages.js +33 -95
- package/dist/tests/test-project-monorepo.js +22 -85
- package/dist/tests/test-project.js +49 -127
- package/package.json +12 -12
|
@@ -1,143 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.SymlinkDependenciesService = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const PackageJson_1 = require("./PackageJson");
|
|
7
|
+
const PluginService_1 = require("./PluginService");
|
|
8
|
+
const PackageManagerService_1 = require("./PackageManagerService");
|
|
9
|
+
class SymlinkDependenciesService {
|
|
10
|
+
static async executeSymlinking(absoluteProjectDir) {
|
|
11
|
+
console.info(`Symlinking dev dependencies...`);
|
|
12
|
+
const installedPlugins = PluginService_1.PluginService.getInstalledPlugins(absoluteProjectDir);
|
|
13
|
+
for (const plugin of installedPlugins) {
|
|
14
|
+
await SymlinkDependenciesService.symlinkPluginDependencies(absoluteProjectDir, plugin);
|
|
15
|
+
}
|
|
16
|
+
console.info(`Symlinking dev dependencies done!`);
|
|
47
17
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
SymlinkDependenciesService.symlinkPluginDependencies = function (absoluteProjectDir, plugin) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
-
var pluginDependencies, projectDependencyPath, pluginDependenciesPath, _i, pluginDependencies_1, pluginDependency, pluginDependencyPath, projectPluginDependencyPath;
|
|
78
|
-
return __generator(this, function (_a) {
|
|
79
|
-
switch (_a.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
pluginDependencies = SymlinkDependenciesService.getPluginDependencies(plugin);
|
|
82
|
-
projectDependencyPath = (0, path_1.join)(absoluteProjectDir, SymlinkDependenciesService.DEPENDENCIES_FOLDER);
|
|
83
|
-
return [4 /*yield*/, SymlinkDependenciesService.getPluginDependenciesPath(absoluteProjectDir, plugin, pluginDependencies)];
|
|
84
|
-
case 1:
|
|
85
|
-
pluginDependenciesPath = _a.sent();
|
|
86
|
-
if (projectDependencyPath === pluginDependenciesPath) {
|
|
87
|
-
console.info("- Skipping symlinking ".concat(plugin.shortname, " dependencies, already in node_modules"));
|
|
88
|
-
return [2 /*return*/];
|
|
89
|
-
}
|
|
90
|
-
for (_i = 0, pluginDependencies_1 = pluginDependencies; _i < pluginDependencies_1.length; _i++) {
|
|
91
|
-
pluginDependency = pluginDependencies_1[_i];
|
|
92
|
-
pluginDependencyPath = (0, path_1.join)(pluginDependenciesPath, pluginDependency);
|
|
93
|
-
if (!(0, fs_1.existsSync)(pluginDependencyPath)) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
projectPluginDependencyPath = (0, path_1.join)(projectDependencyPath, pluginDependency);
|
|
97
|
-
if ((0, fs_1.existsSync)(projectPluginDependencyPath)) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
console.info("- Symlinking ".concat(pluginDependency));
|
|
101
|
-
SymlinkDependenciesService.symlinkDependency(pluginDependencyPath, projectPluginDependencyPath);
|
|
102
|
-
}
|
|
103
|
-
return [2 /*return*/];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
SymlinkDependenciesService.getPluginDependencies = function (plugin) {
|
|
109
|
-
var pluginPackageJson = PackageJson_1.PackageJson.fromDirPath(plugin.path);
|
|
18
|
+
static async symlinkPluginDependencies(absoluteProjectDir, plugin) {
|
|
19
|
+
const pluginDependencies = SymlinkDependenciesService.getPluginDependencies(plugin);
|
|
20
|
+
const projectDependencyPath = (0, path_1.join)(absoluteProjectDir, SymlinkDependenciesService.DEPENDENCIES_FOLDER);
|
|
21
|
+
const pluginDependenciesPath = await SymlinkDependenciesService.getPluginDependenciesPath(absoluteProjectDir, plugin, pluginDependencies);
|
|
22
|
+
if (projectDependencyPath === pluginDependenciesPath) {
|
|
23
|
+
console.info(`- Skipping symlinking ${plugin.shortname} dependencies, already in node_modules`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
for (const pluginDependency of pluginDependencies) {
|
|
27
|
+
const pluginDependencyPath = (0, path_1.join)(pluginDependenciesPath, pluginDependency);
|
|
28
|
+
if (!(0, fs_1.existsSync)(pluginDependencyPath)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const projectPluginDependencyPath = (0, path_1.join)(projectDependencyPath, pluginDependency);
|
|
32
|
+
if ((0, fs_1.existsSync)(projectPluginDependencyPath)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
console.info(`- Symlinking ${pluginDependency}`);
|
|
36
|
+
SymlinkDependenciesService.symlinkDependency(pluginDependencyPath, projectPluginDependencyPath);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
static getPluginDependencies(plugin) {
|
|
40
|
+
const pluginPackageJson = PackageJson_1.PackageJson.fromDirPath(plugin.path);
|
|
110
41
|
return pluginPackageJson.getDependenciesPackageNames();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return [2 /*return*/, pluginDependenciesPath];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return [4 /*yield*/, PackageManagerService_1.PackageManagerService.getNodeModulesPath(absoluteProjectDir)];
|
|
128
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
SymlinkDependenciesService.symlinkDependency = function (pluginDependencyPath, projectPluginDependencyPath) {
|
|
134
|
-
var pluginDependencyParentFolder = (0, path_1.join)(projectPluginDependencyPath, "..");
|
|
42
|
+
}
|
|
43
|
+
static async getPluginDependenciesPath(absoluteProjectDir, plugin, pluginDependencies) {
|
|
44
|
+
const pluginDependenciesPath = (0, path_1.join)(plugin.path, SymlinkDependenciesService.DEPENDENCIES_FOLDER);
|
|
45
|
+
if ((0, fs_1.existsSync)(pluginDependenciesPath)) {
|
|
46
|
+
const hasAnyPluginDependency = pluginDependencies.some((pluginDependency) => (0, fs_1.existsSync)((0, path_1.join)(pluginDependenciesPath, pluginDependency)));
|
|
47
|
+
if (hasAnyPluginDependency) {
|
|
48
|
+
return pluginDependenciesPath;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return await PackageManagerService_1.PackageManagerService.getNodeModulesPath(absoluteProjectDir);
|
|
52
|
+
}
|
|
53
|
+
static symlinkDependency(pluginDependencyPath, projectPluginDependencyPath) {
|
|
54
|
+
const pluginDependencyParentFolder = (0, path_1.join)(projectPluginDependencyPath, "..");
|
|
135
55
|
if (!(0, fs_1.existsSync)(pluginDependencyParentFolder)) {
|
|
136
56
|
(0, fs_1.mkdirSync)(pluginDependencyParentFolder, { recursive: true });
|
|
137
57
|
}
|
|
138
58
|
(0, fs_1.symlinkSync)(pluginDependencyPath, projectPluginDependencyPath);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return SymlinkDependenciesService;
|
|
142
|
-
}());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
143
61
|
exports.SymlinkDependenciesService = SymlinkDependenciesService;
|
|
62
|
+
SymlinkDependenciesService.DEPENDENCIES_FOLDER = "node_modules";
|
|
@@ -1,155 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.AbstractPackageManagerAdapter = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
class AbstractPackageManagerAdapter {
|
|
7
|
+
async getVersion(packageManager, dirPath) {
|
|
8
|
+
const raw = (await this.execCommand([packageManager, "--version"], dirPath, true)).trim();
|
|
9
|
+
const match = raw.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
10
|
+
if (!match) {
|
|
11
|
+
return { raw, major: 0, minor: 0, patch: 0 };
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
raw,
|
|
15
|
+
major: Number(match[1]),
|
|
16
|
+
minor: Number(match[2]),
|
|
17
|
+
patch: Number(match[3]),
|
|
18
|
+
};
|
|
44
19
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
20
|
+
async execCommand(args, cwd, silent = false) {
|
|
21
|
+
if (Array.isArray(args) && args.length === 0) {
|
|
22
|
+
throw new Error("Command args must not be empty");
|
|
23
|
+
}
|
|
24
|
+
if (typeof args === "string" && args.trim().length === 0) {
|
|
25
|
+
throw new Error("Command args must not be empty");
|
|
26
|
+
}
|
|
27
|
+
if (cwd && !(0, fs_1.existsSync)(cwd)) {
|
|
28
|
+
throw new Error(`Directory "${cwd}" does not exist`);
|
|
29
|
+
}
|
|
30
|
+
let cmd;
|
|
31
|
+
let cmdArgs;
|
|
32
|
+
let useShell = false;
|
|
33
|
+
if (Array.isArray(args)) {
|
|
34
|
+
const shellOperators = [">", "|", "&&", "||", ";", "<", ">>", "2>", "&", "$("];
|
|
35
|
+
const hasShellSyntax = args.some((arg) => {
|
|
36
|
+
const trimmedArg = arg.trim();
|
|
37
|
+
return shellOperators.some((op) => trimmedArg.startsWith(op) ||
|
|
38
|
+
trimmedArg.endsWith(op) ||
|
|
39
|
+
trimmedArg.includes(` ${op} `) ||
|
|
40
|
+
trimmedArg.includes(` ${op}`) ||
|
|
41
|
+
trimmedArg.includes(`${op} `));
|
|
64
42
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
if (hasShellSyntax) {
|
|
95
|
-
cmd = args.join(" ").trim();
|
|
96
|
-
cmdArgs = [];
|
|
97
|
-
useShell = true;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
cmd = args[0];
|
|
101
|
-
cmdArgs = args.slice(1);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
cmd = args;
|
|
106
|
-
cmdArgs = [];
|
|
107
|
-
useShell = true;
|
|
43
|
+
if (hasShellSyntax) {
|
|
44
|
+
cmd = args.join(" ").trim();
|
|
45
|
+
cmdArgs = [];
|
|
46
|
+
useShell = true;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
cmd = args[0];
|
|
50
|
+
cmdArgs = args.slice(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
cmd = args;
|
|
55
|
+
cmdArgs = [];
|
|
56
|
+
useShell = true;
|
|
57
|
+
}
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const child = (0, child_process_1.spawn)(cmd, cmdArgs, {
|
|
60
|
+
stdio: silent ? "pipe" : "inherit",
|
|
61
|
+
shell: useShell,
|
|
62
|
+
windowsVerbatimArguments: true,
|
|
63
|
+
cwd,
|
|
64
|
+
});
|
|
65
|
+
let output = "";
|
|
66
|
+
let error = "";
|
|
67
|
+
child.on("exit", function (code) {
|
|
68
|
+
if (code) {
|
|
69
|
+
return reject(output.length > 0 ? output : error);
|
|
108
70
|
}
|
|
109
|
-
|
|
110
|
-
var child = (0, child_process_1.spawn)(cmd, cmdArgs, {
|
|
111
|
-
stdio: silent ? "pipe" : "inherit",
|
|
112
|
-
shell: useShell,
|
|
113
|
-
windowsVerbatimArguments: true,
|
|
114
|
-
cwd: cwd,
|
|
115
|
-
});
|
|
116
|
-
var output = "";
|
|
117
|
-
var error = "";
|
|
118
|
-
child.on("exit", function (code) {
|
|
119
|
-
if (code) {
|
|
120
|
-
return reject(output.length > 0 ? output : error);
|
|
121
|
-
}
|
|
122
|
-
resolve(output);
|
|
123
|
-
});
|
|
124
|
-
if (child.stdout) {
|
|
125
|
-
child.stdout.on("data", function (data) {
|
|
126
|
-
output += "\n".concat(data);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
if (child.stderr) {
|
|
130
|
-
child.stderr.on("data", function (data) {
|
|
131
|
-
error += "\n".concat(data);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
})];
|
|
71
|
+
resolve(output);
|
|
135
72
|
});
|
|
73
|
+
if (child.stdout) {
|
|
74
|
+
child.stdout.on("data", (data) => {
|
|
75
|
+
output += `\n${data}`;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (child.stderr) {
|
|
79
|
+
child.stderr.on("data", (data) => {
|
|
80
|
+
error += `\n${data}`;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
136
83
|
});
|
|
137
|
-
}
|
|
138
|
-
|
|
84
|
+
}
|
|
85
|
+
parseJsonLines(output) {
|
|
139
86
|
return output
|
|
140
87
|
.split(/\r?\n/)
|
|
141
|
-
.map(
|
|
142
|
-
.filter(
|
|
143
|
-
.map(
|
|
88
|
+
.map((line) => line.trim())
|
|
89
|
+
.filter((line) => line.length > 0)
|
|
90
|
+
.map((line) => {
|
|
144
91
|
try {
|
|
145
92
|
return JSON.parse(line);
|
|
146
93
|
}
|
|
147
|
-
catch
|
|
94
|
+
catch {
|
|
148
95
|
return undefined;
|
|
149
96
|
}
|
|
150
97
|
})
|
|
151
|
-
.filter(
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
}());
|
|
98
|
+
.filter((entry) => entry !== undefined);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
155
101
|
exports.AbstractPackageManagerAdapter = AbstractPackageManagerAdapter;
|