Skip to content

Commit

Permalink
update deps and cleanup code (#32)
Browse files Browse the repository at this point in the history
* update deps and cleanup code

* remove node 4/6 in ci as they are unmaintained
  • Loading branch information
thomasruiz authored and SBoudrias committed Aug 14, 2019
1 parent 30c5652 commit edf8387
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '12'
- '10'
- '8'
- '6'
- '4'
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ module.exports = (message, options) => {
* Better implementations welcome :)
*/

let maxLength = 24;
const styledIndexes = {};
let completedString = '';
let maxLength = 24;
let topOffset = 4;
let completedString = '';

// Amount of characters of the yeoman character »column« → ` /___A___\ /`
const YEOMAN_CHARACTER_WIDTH = 17;

// Amount of characters of the default top frame of the speech bubble → `╭──────────────────────────╮`
const DEFAULT_TOP_FRAME_WIDTH = 28;

// Amount of characters of a total line
let TOTAL_CHARACTERS_PER_LINE = YEOMAN_CHARACTER_WIDTH + DEFAULT_TOP_FRAME_WIDTH;

// The speech bubble will overflow the Yeoman character if the message is too long.
const MAX_MESSAGE_LINES_BEFORE_OVERFLOW = 7;

// Amount of characters of a total line
let TOTAL_CHARACTERS_PER_LINE = YEOMAN_CHARACTER_WIDTH + DEFAULT_TOP_FRAME_WIDTH;

if (options.maxLength) {
maxLength = stripAnsi(message).toLowerCase().split(' ').sort()[0].length;

Expand Down Expand Up @@ -104,7 +104,7 @@ module.exports = (message, options) => {
let offset = 0;

for (let i = 0; i < spacesIndex.length; i++) {
let char = completedString[spacesIndex[i] - offset];
const char = completedString[spacesIndex[i] - offset];
if (char) {
if (char !== ' ') {
offset += 1;
Expand Down Expand Up @@ -135,7 +135,9 @@ module.exports = (message, options) => {

if (styledIndexes[charIndex]) {
return styledIndexes[charIndex] + char;
} else if (hasContinuedStyle >= 2) {
}

if (hasContinuedStyle >= 2) {
return continuedStyle + char;
}

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
"ansi"
],
"dependencies": {
"ansi-regex": "^2.0.0",
"ansi-styles": "^3.0.0",
"chalk": "^1.0.0",
"cli-boxes": "^1.0.0",
"ansi-regex": "^4.1.0",
"ansi-styles": "^4.0.0",
"chalk": "^2.4.2",
"cli-boxes": "^2.2.0",
"pad-component": "0.0.1",
"string-width": "^2.0.0",
"strip-ansi": "^3.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^5.2.0",
"taketalk": "^1.0.0",
"wrap-ansi": "^2.0.0"
"wrap-ansi": "^6.0.0"
},
"devDependencies": {
"mocha": "^3.2.0",
"xo": "^0.17.0"
"mocha": "^6.2.0",
"xo": "^0.24.0"
},
"xo": {
"space": true
Expand Down
2 changes: 1 addition & 1 deletion test/manual-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const chalk = require('chalk');
const yosay = require('../');
const yosay = require('..');

/*
* Yo. Fire this file locally with `node test/manual-test.js` at least after you
Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const yosay = require('../');
const yosay = require('..');

const getFixturePath = testName => path.join(__dirname, 'fixture', `${testName}.json`);

const getAssertResult = (testName, expected, done) => fs.readFile(getFixturePath(testName), (err, data) => {
assert.ifError(err);
assert.equal(JSON.parse(data), expected);
assert.strict.equal(JSON.parse(data), expected);
done();
});

Expand Down

0 comments on commit edf8387

Please sign in to comment.