UNPKG

1.78 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.chmod = void 0;
4var tslib_1 = require("tslib");
5var common_1 = require("../common");
6function chmod(args) {
7 if (args === void 0) { args = {}; }
8 return tslib_1.__awaiter(this, void 0, void 0, function () {
9 var dir, permissions, silent, log, bin, files, cmds, res;
10 return tslib_1.__generator(this, function (_a) {
11 switch (_a.label) {
12 case 0: return [4, common_1.paths.closestParentOf('node_modules')];
13 case 1:
14 dir = _a.sent();
15 if (!dir) {
16 return [2, common_1.result.fail("A module 'package.json' could not be found")];
17 }
18 permissions = args.permissions, silent = args.silent;
19 log = common_1.getLog(silent);
20 bin = common_1.fs.join(dir, 'node_modules/.bin');
21 return [4, common_1.fs.readdir(bin)];
22 case 2:
23 files = (_a.sent()).map(function (name) { return common_1.fs.join(bin, name); });
24 cmds = files.map(function (path) {
25 return {
26 title: "chmod " + permissions + " .bin/" + common_1.fs.basename(path),
27 cmd: "chmod " + permissions + " " + path,
28 };
29 });
30 log.info();
31 return [4, common_1.exec.cmd.runList(cmds, { silent: silent, concurrent: true })];
32 case 3:
33 res = _a.sent();
34 res.errors.log({ log: log });
35 return [2, res];
36 }
37 });
38 });
39}
40exports.chmod = chmod;