msync
Version:
Easily manage building and syncing multiple node-modules in a flexibly defined workspace.
74 lines (73 loc) • 3.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cmd = exports.args = exports.description = exports.alias = exports.name = void 0;
var tslib_1 = require("tslib");
var common_1 = require("../common");
exports.name = 'hidden';
exports.alias = 'h';
exports.description = 'Find and copy out all hidden configuration files.';
exports.args = {};
function cmd(args) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var settings, base, targetDir, count, _i, _a, pattern, paths, _b, paths_1, path, relative, filename, dir;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, (0, common_1.loadSettings)({ npm: false, spinner: true })];
case 1:
settings = _c.sent();
if (!settings) {
common_1.log.warn.yellow(common_1.constants.CONFIG_NOT_FOUND_ERROR);
return [2];
}
base = common_1.fs.resolve('.');
targetDir = common_1.fs.join(base, '.msync.hidden');
return [4, common_1.fs.remove(targetDir)];
case 2:
_c.sent();
return [4, common_1.fs.ensureDir(targetDir)];
case 3:
_c.sent();
count = 0;
_i = 0, _a = settings.hidden;
_c.label = 4;
case 4:
if (!(_i < _a.length)) return [3, 10];
pattern = _a[_i];
return [4, common_1.fs.glob.find(common_1.fs.join(base, pattern))];
case 5:
paths = _c.sent();
paths = paths.filter(function (path) { return !path.includes('node_modules/'); });
_b = 0, paths_1 = paths;
_c.label = 6;
case 6:
if (!(_b < paths_1.length)) return [3, 9];
path = paths_1[_b];
relative = path.substring(base.length + 1);
filename = common_1.fs.basename(relative);
dir = relative.substring(0, relative.length - filename.length);
return [4, common_1.fs.copy(path, common_1.fs.join(targetDir, relative))];
case 7:
_c.sent();
common_1.log.info.gray("\u2022 ".concat(dir).concat(common_1.log.white(filename)));
count++;
_c.label = 8;
case 8:
_b++;
return [3, 6];
case 9:
_i++;
return [3, 4];
case 10:
if (count === 0) {
common_1.log.info.gray("No hidden files found");
}
else {
common_1.log.info();
common_1.log.info.gray("saved files into: ".concat(common_1.log.white(targetDir)));
}
return [2];
}
});
});
}
exports.cmd = cmd;