UNPKG

@platform/react.ssr

Version:

A lightweight SSR (server-side-rendering) system for react apps bundled with ParcelJS and hosted on S3.

43 lines (42 loc) 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var common_1 = require("../common"); function dir(parentDir) { var api = { latest: function () { return tslib_1.__awaiter(this, void 0, void 0, function () { var dirs; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4, api.semver()]; case 1: dirs = _a.sent(); return [2, dirs[dirs.length - 1]]; } }); }); }, semver: function (options) { if (options === void 0) { options = {}; } return tslib_1.__awaiter(this, void 0, void 0, function () { var _a, sort, paths, names, ascending; return tslib_1.__generator(this, function (_b) { switch (_b.label) { case 0: _a = options.sort, sort = _a === void 0 ? 'ASC' : _a; parentDir = common_1.fs.resolve(parentDir); return [4, common_1.fs.glob.find(common_1.fs.join(parentDir, '*/'), { includeDirs: true })]; case 1: paths = _b.sent(); names = paths.map(function (path) { return common_1.fs.basename(path); }).filter(function (name) { return common_1.semver.valid(name); }); ascending = common_1.semver.sort(names).map(function (name) { return common_1.fs.join(parentDir, name); }); return [2, sort === 'DESC' ? ascending.reverse() : ascending]; } }); }); }, }; return api; } exports.dir = dir;