mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-16 07:13:46 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
43
node_modules/cli-truncate/index.js
generated
vendored
Normal file
43
node_modules/cli-truncate/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
var sliceAnsi = require('slice-ansi');
|
||||
var stringWidth = require('string-width');
|
||||
|
||||
module.exports = function (input, columns, options) {
|
||||
options = options || {};
|
||||
|
||||
var position = options.position || 'end';
|
||||
var ellipsis = '…';
|
||||
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError('Expected `input` to be a string, got ' + typeof input);
|
||||
}
|
||||
|
||||
if (typeof columns !== 'number') {
|
||||
throw new TypeError('Expected `columns` to be a number, got ' + typeof columns);
|
||||
}
|
||||
|
||||
if (columns < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (columns === 1) {
|
||||
return ellipsis;
|
||||
}
|
||||
|
||||
var length = stringWidth(input);
|
||||
|
||||
if (length <= columns) {
|
||||
return input;
|
||||
}
|
||||
|
||||
if (position === 'start') {
|
||||
return ellipsis + sliceAnsi(input, length - columns + 1, length);
|
||||
} else if (position === 'middle') {
|
||||
var half = Math.floor(columns / 2);
|
||||
return sliceAnsi(input, 0, half) + ellipsis + sliceAnsi(input, length - (columns - half) + 1, length);
|
||||
} else if (position === 'end') {
|
||||
return sliceAnsi(input, 0, columns - 1) + ellipsis;
|
||||
}
|
||||
|
||||
throw new Error('Expected `options.position` to be either `start`, `middle` or `end`, got ' + position);
|
||||
};
|
||||
21
node_modules/cli-truncate/license
generated
vendored
Normal file
21
node_modules/cli-truncate/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
42
node_modules/cli-truncate/package.json
generated
vendored
Normal file
42
node_modules/cli-truncate/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "cli-truncate",
|
||||
"version": "0.2.1",
|
||||
"description": "Truncate a string to a specific width in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/cli-truncate",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"truncate",
|
||||
"ellipsis",
|
||||
"text",
|
||||
"limit",
|
||||
"slice",
|
||||
"cli",
|
||||
"terminal",
|
||||
"term",
|
||||
"shell",
|
||||
"width",
|
||||
"ansi"
|
||||
],
|
||||
"dependencies": {
|
||||
"slice-ansi": "0.0.4",
|
||||
"string-width": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
75
node_modules/cli-truncate/readme.md
generated
vendored
Normal file
75
node_modules/cli-truncate/readme.md
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# cli-truncate [](https://travis-ci.org/sindresorhus/cli-truncate)
|
||||
|
||||
> Truncate a string to a specific width in the terminal
|
||||
|
||||
Gracefully handles [ANSI escapes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles). Like a string styled with [`chalk`](https://github.com/chalk/chalk).
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save cli-truncate
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const cliTruncate = require('cli-truncate');
|
||||
|
||||
cliTruncate('unicorn', 4);
|
||||
//=> 'uni…'
|
||||
|
||||
// truncate at different positions
|
||||
cliTruncate('unicorn', 4, {position: 'start'});
|
||||
//=> '…orn'
|
||||
|
||||
cliTruncate('unicorn', 4, {position: 'middle'});
|
||||
//=> 'un…n'
|
||||
|
||||
cliTruncate('\u001b[31municorn\u001b[39m', 4);
|
||||
//=> '\u001b[31muni\u001b[39m…'
|
||||
|
||||
// truncate the paragraph to the terminal width
|
||||
const paragraph = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.';
|
||||
cliTruncate(paragraph, process.stdout.columns));
|
||||
//=> 'Lorem ipsum dolor sit amet, consectetuer adipiscing…'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### cliTruncate(input, columns, [options])
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string`
|
||||
|
||||
Text to truncate.
|
||||
|
||||
#### columns
|
||||
|
||||
Type: `number`
|
||||
|
||||
Columns to occupy in the terminal.
|
||||
|
||||
#### options
|
||||
|
||||
##### position
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'end'`<br>
|
||||
Values: `'start'`, `'middle'`, `'end'`
|
||||
|
||||
Position to truncate the string.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
Reference in New Issue
Block a user