@inquirer/core 0.0.18-alpha.0 → 0.0.19-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +2 -2
  2. package/lib/utils.js +5 -10
  3. package/package.json +4 -3
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Simon Boudrias
1
+ Copyright (c) 2022 Simon Boudrias
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
19
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
20
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
21
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
22
+ OTHER DEALINGS IN THE SOFTWARE.
package/lib/utils.js CHANGED
@@ -1,3 +1,5 @@
1
+ const wrapAnsi = require('wrap-ansi');
2
+
1
3
  /**
2
4
  * Force line returns at specific width. This function is ANSI code friendly and it'll
3
5
  * ignore invisible codes during width calculation.
@@ -5,15 +7,8 @@
5
7
  * @param {number} width
6
8
  * @return {string}
7
9
  */
8
- exports.breakLines = (content, width) => {
9
- const regex = new RegExp('(?:(?:\\033[[0-9;]*m)*.?){1,' + width + '}', 'g');
10
- return content
10
+ exports.breakLines = (content, width) =>
11
+ content
11
12
  .split('\n')
12
- .flatMap((line) => {
13
- const chunk = line.match(regex);
14
- // Remove the last match as it's always empty
15
- chunk.pop();
16
- return chunk || '';
17
- })
13
+ .map((line) => wrapAnsi(line, width, { trim: false, hard: true }))
18
14
  .join('\n');
19
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/core",
3
- "version": "0.0.18-alpha.0",
3
+ "version": "0.0.19-alpha.0",
4
4
  "description": "Core Inquirer prompt API",
5
5
  "main": "index.js",
6
6
  "repository": "SBoudrias/Inquirer.js",
@@ -21,10 +21,11 @@
21
21
  "mute-stream": "^0.0.8",
22
22
  "run-async": "^2.3.0",
23
23
  "string-width": "^4.1.0",
24
- "strip-ansi": "^6.0.0"
24
+ "strip-ansi": "^6.0.0",
25
+ "wrap-ansi": "^7.0.0"
25
26
  },
26
27
  "publishConfig": {
27
28
  "access": "public"
28
29
  },
29
- "gitHead": "e71313db1a6e26f501b58d75a9d3acf53dab5da7"
30
+ "gitHead": "9baee326b04b4e8565e815b1fa577c36e0b93727"
30
31
  }