Projects STRLCPY cfonts Commits 9f34ffcc
🤬
  • ■ ■ ■ ■ ■ ■
    README.md
    skipped 201 lines
    202 202  - `left` _(default)_
    203 203  - `center`
    204 204  - `right`
     205 +- `top` _(Will be ignored if used with the spaceless option)_
     206 +- `bottom` _(Will be ignored if used with the spaceless option)
    205 207   
    206 208  ```shell
    207 209  $ cfonts "text" --align "center"
    skipped 302 lines
    510 512   
    511 513   
    512 514  ## Release History
     515 +* 2.9.0 - added `top` and `bottom` align options
    513 516  * 2.8.6 - bumped dependencies
    514 517  * 2.8.5 - renamed branches
    515 518  * 2.8.4 - fixed block double quote
    skipped 57 lines
  • ■ ■ ■ ■ ■ ■
    package.json
    1 1  {
    2 2   "name": "cfonts",
    3 3   "description": "Sexy fonts for the console",
    4  - "version": "2.8.6",
     4 + "version": "2.9.0",
    5 5   "homepage": "https://github.com/dominikwilkowski/cfonts",
    6 6   "author": {
    7 7   "name": "Dominik Wilkowski",
    skipped 39 lines
    47 47   "nuke": "rm -rf lib && rm -rf node_modules && rm yarn.lock"
    48 48   },
    49 49   "devDependencies": {
    50  - "@babel/cli": "^7.10.5",
    51  - "@babel/core": "^7.10.5",
    52  - "@babel/preset-env": "^7.10.4",
     50 + "@babel/cli": "^7.12.8",
     51 + "@babel/core": "^7.12.9",
     52 + "@babel/preset-env": "^7.12.7",
    53 53   "@types/node": "latest",
    54 54   "coveralls": "^3.1.0",
    55  - "eslint": "^7.4.0",
    56  - "jest-cli": "^26.1.0",
    57  - "onchange": "^7.0.2",
    58  - "typescript": "^3.9.7"
     55 + "eslint": "^7.15.0",
     56 + "jest-cli": "^26.6.3",
     57 + "onchange": "^7.1.0",
     58 + "typescript": "^4.1.2"
    59 59   },
    60 60   "peerDependencies": {},
    61 61   "dependencies": {
    skipped 74 lines
  • ■ ■ ■ ■ ■
    src/Render.js
    skipped 213 lines
    214 214   }
    215 215   
    216 216   if( OPTIONS.space ) { // add space
    217  - output[ 0 ] = `\n\n${ output[ 0 ] }`;
    218  - output[ output.length - 1 ] = `${ output[ output.length - 1 ] }\n\n`;
     217 + if( OPTIONS.align === 'top' ) {
     218 + output[ output.length - 1 ] = `${ output[ output.length - 1 ] }\n\n\n\n`;
     219 + }
     220 + else if( OPTIONS.align === 'bottom' ) {
     221 + output[ 0 ] = `\n\n\n\n${ output[ 0 ] }`;
     222 + }
     223 + else {
     224 + output[ 0 ] = `\n\n${ output[ 0 ] }`;
     225 + output[ output.length - 1 ] = `${ output[ output.length - 1 ] }\n\n`;
     226 + }
    219 227   }
    220 228   
    221 229   if( OPTIONS.background !== 'transparent' && OPTIONS.env === 'node' ) {
    skipped 29 lines
  • ■ ■ ■ ■ ■ ■
    src/constants.js
    skipped 106 lines
    107 107   'left',
    108 108   'center',
    109 109   'right',
     110 + 'top',
     111 + 'bottom',
    110 112  ];
    111 113   
    112 114  const FONTFACES = {
    skipped 142 lines
  • ■ ■ ■ ■ ■ ■
    test/unit/AlignText.spec.js
    skipped 28 lines
    29 29   expect( AlignText( ['x'], 1, 1, 'left' ) ).toEqual( ['x'] );
    30 30  });
    31 31   
     32 + 
     33 +test(`AlignText - Should do nothing when align top or bottom`, () => {
     34 + expect( AlignText( ['x'], 1, 1, 'top', { width: 21 } ) ).toEqual( ['x'] );
     35 + expect( AlignText( ['x'], 1, 1, 'top', { width: 1 } ) ).toEqual( ['x'] );
     36 + expect( AlignText( ['x'], 1, 1, 'bottom', { width: 21 } ) ).toEqual( ['x'] );
     37 + expect( AlignText( ['x'], 1, 1, 'bottom', { width: 1 } ) ).toEqual( ['x'] );
     38 +});
     39 + 
  • ■ ■ ■ ■ ■ ■
    test/unit/Render.spec.js
    skipped 345 lines
    346 346  });
    347 347   
    348 348   
     349 +test(`Render - Top align block font`, () => {
     350 + const test = Render( 'text', {
     351 + align: 'top',
     352 + }, false, 1, { width: 50, height: 10 });
     353 + 
     354 + expect( test.string ).toBe(
     355 + ' ████████╗ ███████╗ ██╗ ██╗ ████████╗ \n' +
     356 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ \n' +
     357 + ' ██║ █████╗ ╚███╔╝ ██║ \n' +
     358 + ' ██║ ██╔══╝ ██╔██╗ ██║ \n' +
     359 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ \n' +
     360 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ \n\n\n\n'
     361 + );
     362 + expect( test.array ).toEqual([
     363 + ' ████████╗ ███████╗ ██╗ ██╗ ████████╗ ',
     364 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ ',
     365 + ' ██║ █████╗ ╚███╔╝ ██║ ',
     366 + ' ██║ ██╔══╝ ██╔██╗ ██║ ',
     367 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ ',
     368 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ \n\n\n\n',
     369 + ]);
     370 + expect( test.lines ).toBe( 1 );
     371 + expect( test.options ).toEqual({
     372 + font: 'block',
     373 + align: 'top',
     374 + colors: [],
     375 + background: 'transparent',
     376 + letterSpacing: 1,
     377 + lineHeight: 1,
     378 + space: true,
     379 + maxLength: 0,
     380 + gradient: false,
     381 + independentGradient: false,
     382 + transitionGradient: false,
     383 + env: 'node',
     384 + });
     385 +});
     386 + 
     387 + 
     388 +test(`Render - Bottom align block font`, () => {
     389 + const test = Render( 'text', {
     390 + align: 'bottom',
     391 + }, false, 1, { width: 50, height: 10 });
     392 + 
     393 + expect( test.string ).toBe(
     394 + '\n\n\n\n' +
     395 + ' ████████╗ ███████╗ ██╗ ██╗ ████████╗ \n' +
     396 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ \n' +
     397 + ' ██║ █████╗ ╚███╔╝ ██║ \n' +
     398 + ' ██║ ██╔══╝ ██╔██╗ ██║ \n' +
     399 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ \n' +
     400 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ '
     401 + );
     402 + expect( test.array ).toEqual([
     403 + '\n\n\n\n ████████╗ ███████╗ ██╗ ██╗ ████████╗ ',
     404 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ ',
     405 + ' ██║ █████╗ ╚███╔╝ ██║ ',
     406 + ' ██║ ██╔══╝ ██╔██╗ ██║ ',
     407 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ ',
     408 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ',
     409 + ]);
     410 + expect( test.lines ).toBe( 1 );
     411 + expect( test.options ).toEqual({
     412 + font: 'block',
     413 + align: 'bottom',
     414 + colors: [],
     415 + background: 'transparent',
     416 + letterSpacing: 1,
     417 + lineHeight: 1,
     418 + space: true,
     419 + maxLength: 0,
     420 + gradient: false,
     421 + independentGradient: false,
     422 + transitionGradient: false,
     423 + env: 'node',
     424 + });
     425 +});
     426 + 
     427 + 
     428 +test(`Render - Ignore alignment top when combining it with space option`, () => {
     429 + const test = Render( 'text', {
     430 + space: false,
     431 + align: 'top',
     432 + }, false, 1, { width: 100, height: 10 } );
     433 + 
     434 + expect( test.string ).toBe(
     435 + ' ████████╗ ███████╗ ██╗ ██╗ ████████╗ \n' +
     436 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ \n' +
     437 + ' ██║ █████╗ ╚███╔╝ ██║ \n' +
     438 + ' ██║ ██╔══╝ ██╔██╗ ██║ \n' +
     439 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ \n' +
     440 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ '
     441 + );
     442 + expect( test.array ).toEqual([
     443 + ' ████████╗ ███████╗ ██╗ ██╗ ████████╗ ',
     444 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ ',
     445 + ' ██║ █████╗ ╚███╔╝ ██║ ',
     446 + ' ██║ ██╔══╝ ██╔██╗ ██║ ',
     447 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ ',
     448 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ',
     449 + ]);
     450 + expect( test.lines ).toBe( 1 );
     451 + expect( test.options ).toEqual({
     452 + font: 'block',
     453 + align: 'top',
     454 + colors: [],
     455 + background: 'transparent',
     456 + letterSpacing: 1,
     457 + lineHeight: 1,
     458 + space: false,
     459 + maxLength: 0,
     460 + gradient: false,
     461 + independentGradient: false,
     462 + transitionGradient: false,
     463 + env: 'node',
     464 + });
     465 +});
     466 + 
     467 + 
     468 +test(`Render - Ignore alignment bottom when combining it with space option`, () => {
     469 + const test = Render( 'text', {
     470 + space: false,
     471 + align: 'bottom',
     472 + }, false, 1, { width: 100, height: 10 } );
     473 + 
     474 + expect( test.string ).toBe(
     475 + ' ████████╗ ███████╗ ██╗ ██╗ ████████╗ \n' +
     476 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ \n' +
     477 + ' ██║ █████╗ ╚███╔╝ ██║ \n' +
     478 + ' ██║ ██╔══╝ ██╔██╗ ██║ \n' +
     479 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ \n' +
     480 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ '
     481 + );
     482 + expect( test.array ).toEqual([
     483 + ' ████████╗ ███████╗ ██╗ ██╗ ████████╗ ',
     484 + ' ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ ',
     485 + ' ██║ █████╗ ╚███╔╝ ██║ ',
     486 + ' ██║ ██╔══╝ ██╔██╗ ██║ ',
     487 + ' ██║ ███████╗ ██╔╝ ██╗ ██║ ',
     488 + ' ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ',
     489 + ]);
     490 + expect( test.lines ).toBe( 1 );
     491 + expect( test.options ).toEqual({
     492 + font: 'block',
     493 + align: 'bottom',
     494 + colors: [],
     495 + background: 'transparent',
     496 + letterSpacing: 1,
     497 + lineHeight: 1,
     498 + space: false,
     499 + maxLength: 0,
     500 + gradient: false,
     501 + independentGradient: false,
     502 + transitionGradient: false,
     503 + env: 'node',
     504 + });
     505 +});
     506 + 
     507 + 
    349 508  test(`Render - Break into new line on smaller viewports`, () => {
    350 509   const test = Render( 'text', {}, false, 1, { width: 20, height: 10 });
    351 510   
    skipped 401 lines
  • yarn.lock
    Diff is too large to be displayed.
Please wait...
Page is in error, reload to recover