UNPKG

1.08 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var execa = require("execa");
5/**
6 * 判断指定命令行是否安装
7 *
8 * @param cmd 命令行
9 * @param args 判断是否安装时的参数,默认为`['--version']`
10 */
11function isCmdInstalled(cmd, args) {
12 if (args === void 0) { args = ['--version']; }
13 return tslib_1.__awaiter(this, void 0, void 0, function () {
14 var e_1;
15 return tslib_1.__generator(this, function (_a) {
16 switch (_a.label) {
17 case 0:
18 _a.trys.push([0, 2, , 3]);
19 return [4 /*yield*/, execa(cmd, args)];
20 case 1:
21 _a.sent();
22 return [2 /*return*/, true];
23 case 2:
24 e_1 = _a.sent();
25 return [2 /*return*/, false];
26 case 3: return [2 /*return*/];
27 }
28 });
29 });
30}
31exports.default = isCmdInstalled;
32//# sourceMappingURL=isCmdInstalled.js.map
\No newline at end of file