UNPKG

@platform/ts

Version:

TypesScript build, prepare and publish toolchain.

41 lines (40 loc) 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.chmod = void 0; var tslib_1 = require("tslib"); var common_1 = require("../common"); function chmod(args) { if (args === void 0) { args = {}; } return tslib_1.__awaiter(this, void 0, void 0, function () { var dir, permissions, silent, log, bin, files, cmds, res; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4, common_1.paths.closestParentOf('node_modules')]; case 1: dir = _a.sent(); if (!dir) { return [2, common_1.result.fail("A module 'package.json' could not be found")]; } permissions = args.permissions, silent = args.silent; log = (0, common_1.getLog)(silent); bin = common_1.fs.join(dir, 'node_modules/.bin'); return [4, common_1.fs.readdir(bin)]; case 2: files = (_a.sent()).map(function (name) { return common_1.fs.join(bin, name); }); cmds = files.map(function (path) { return { title: "chmod ".concat(permissions, " .bin/").concat(common_1.fs.basename(path)), cmd: "chmod ".concat(permissions, " ").concat(path), }; }); log.info(); return [4, common_1.exec.cmd.runList(cmds, { silent: silent, concurrent: true })]; case 3: res = _a.sent(); res.errors.log({ log: log }); return [2, res]; } }); }); } exports.chmod = chmod;