UNPKG

@best/console-stream

Version:

Best stdout stream wrapper

24 lines 753 B
"use strict"; /* * Copyright (c) 2019, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = trimPath; function trimPath(dirname, trim) { const parts = dirname.split('/'); const first = parts.shift(); const trimmedPath = parts.reduce((tmp, part) => { if (trim > 0) { trim -= part.length; return tmp; } else { return `${tmp}/${part}`; } }, ''); return trim > 0 ? `...${trimmedPath}` : `${first}/...${trimmedPath}`; } //# sourceMappingURL=trim-path.js.map