Skip to content

Commit fa6ecbd

Browse files
committedJun 8, 2021
chore(deps): upgrade to latest stable; fix audit
- fixes all security vulnerabilities (`npm audit` is now clean) - remove deprecated coffee-script package. make mocha use new coffeescript's register. - upgrade coffeescript to v2. had to change SpecialString usages to new SpecialString. - remove unmaintained "mocha-pretty-spec-reporter" (has security vulnerability) - remove unused "underscore". - replace "jitter" usage with official watch capability.
1 parent 4a7e401 commit fa6ecbd

File tree

8 files changed

+390
-693
lines changed

8 files changed

+390
-693
lines changed
 

‎.mocharc.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require: 'coffee-script/register'
1+
require: 'coffeescript/register'
22
recursive: true
33
reporter: 'spec'
44
ui: 'bdd'

‎package-lock.json

+347-646
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+14-18
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,26 @@
44
"description": "Stylish console.log for node",
55
"main": "lib/RenderKid.js",
66
"dependencies": {
7-
"css-select": "^2.0.2",
8-
"dom-converter": "^0.2",
9-
"htmlparser2": "^3.10.1",
10-
"lodash": "^4.17.20",
11-
"strip-ansi": "^3.0.0"
7+
"css-select": "^4.1.3",
8+
"dom-converter": "^0.2.0",
9+
"htmlparser2": "^6.1.0",
10+
"lodash": "^4.17.21",
11+
"strip-ansi": "^6.0.0"
1212
},
1313
"devDependencies": {
14-
"chai": "^4.1.2",
15-
"chai-changes": "^1.3.4",
16-
"chai-fuzzy": "^1.5.0",
17-
"coffee-script": "~1.8.0",
18-
"coffeescript": "^1.12.7",
19-
"jitter": "^1.3.0",
20-
"mocha": "^8.2.0",
21-
"mocha-pretty-spec-reporter": "0.1.0-beta.2",
22-
"sinon": "^1.14.1",
23-
"sinon-chai": "^2.7.0",
24-
"underscore": "^1.8.3"
14+
"chai": "^4.3.4",
15+
"chai-changes": "^1.3.6",
16+
"chai-fuzzy": "^1.6.1",
17+
"coffeescript": "^2.5.1",
18+
"mocha": "^9.0.0",
19+
"sinon": "^11.1.1",
20+
"sinon-chai": "^3.7.0"
2521
},
2622
"scripts": {
2723
"test": "mocha \"test/**/*.coffee\"",
28-
"test:watch": "mocha \"test/**/*.coffee\" --watch",
24+
"test:watch": "npm run test -- --watch",
2925
"compile": "coffee --bare --compile --output ./lib ./src",
30-
"compile:watch": "jitter src lib -b",
26+
"compile:watch": "coffee --watch --bare --compile --output ./lib ./src",
3127
"watch": "npm run compile:watch & npm run test:watch",
3228
"winwatch": "start/b npm run compile:watch & npm run test:watch",
3329
"prepublish": "npm run compile"

‎src/Layout.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = class Layout
3333

3434
_appendLine: (text) ->
3535
@_append text
36-
s = SpecialString(text)
36+
s = new SpecialString(text)
3737
if s.length < @_config.terminalWidth
3838
@_append '<none>\n</none>'
3939

‎src/layout/Block.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ module.exports = class Block
148148
_writeInline: (str) ->
149149
# special characters (such as <bg-white>) don't require
150150
# any wrapping...
151-
if SpecialString(str).isOnlySpecialChars()
151+
if new SpecialString(str).isOnlySpecialChars()
152152
# ... and directly get appended to the layout.
153153
@_layout._append str
154154
return
@@ -205,21 +205,21 @@ module.exports = class Block
205205
# etc, and appends it to the layout.
206206
_writeLine: (str) ->
207207
# we'll be cutting from our string as we go
208-
remaining = SpecialString str
208+
remaining = new SpecialString str
209209

210210
# this will continue until nothing is left of our block.
211211
loop
212212
# left margin...
213213
toPrepend = @_toPrependToLine()
214214

215215
# ... and its length
216-
toPrependLength = SpecialString(toPrepend).length
216+
toPrependLength = new SpecialString(toPrepend).length
217217

218218
# right margin...
219219
toAppend = @_toAppendToLine()
220220

221221
# ... and its length
222-
toAppendLength = SpecialString(toAppend).length
222+
toAppendLength = new SpecialString(toAppend).length
223223

224224
# how much room is left for content
225225
roomLeft = @_layout._config.terminalWidth - (toPrependLength + toAppendLength)

‎src/layout/SpecialString.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module.exports = class SpecialString
113113

114114
@_str = before + after
115115
do @_reset
116-
SpecialString cut
116+
new SpecialString cut
117117

118118
@_countChars: (text, cb) ->
119119
while text.length isnt 0

‎src/layout/block/linePrependor/Default.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = class DefaultLinePrependor extends require './_LinePrependor'
1010
_render: (inherited, options) ->
1111
if @_lineNo is 0 and bullet = @_config.bullet
1212
char = bullet.char
13-
charLen = SpecialString(char).length
13+
charLen = new SpecialString(char).length
1414
alignment = bullet.alignment
1515
space = @_config.amount
1616
toWrite = char

‎test/layout/SpecialString.coffee

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,80 @@ S = require '../../src/layout/SpecialString'
33
describe "SpecialString", ->
44
describe 'SpecialString()', ->
55
it 'should return instance', ->
6-
S('s').should.be.instanceOf S
6+
new S('s').should.be.instanceOf S
77

88
describe 'length()', ->
99
it 'should return correct length for normal text', ->
10-
S('hello').length.should.equal 5
10+
new S('hello').length.should.equal 5
1111

1212
it 'should return correct length for text containing tabs and tags', ->
13-
S('<a>he<you />l\tlo</a>').length.should.equal 13
13+
new S('<a>he<you />l\tlo</a>').length.should.equal 13
1414

1515
it "shouldn't count empty tags as tags", ->
16-
S('<>><').length.should.equal 4
16+
new S('<>><').length.should.equal 4
1717

1818
it "should count length of single tag as 0", ->
19-
S('<html>').length.should.equal 0
19+
new S('<html>').length.should.equal 0
2020

2121
it "should work correctly with html quoted characters", ->
22-
S(' &gt;&lt; &sp;').length.should.equal 5
22+
new S(' &gt;&lt; &sp;').length.should.equal 5
2323

2424
describe 'splitIn()', ->
2525
it "should work correctly with normal text", ->
26-
S("123456").splitIn(3).should.be.like ['123', '456']
26+
new S("123456").splitIn(3).should.be.like ['123', '456']
2727

2828
it "should work correctly with normal text containing tabs and tags", ->
29-
S("12\t3<hello>456").splitIn(3).should.be.like ['12', '\t', '3<hello>45', '6']
29+
new S("12\t3<hello>456").splitIn(3).should.be.like ['12', '\t', '3<hello>45', '6']
3030

3131
it "should not trimLeft all lines when trimLeft is no", ->
32-
S('abc def').splitIn(3).should.be.like ['abc', ' de', 'f']
32+
new S('abc def').splitIn(3).should.be.like ['abc', ' de', 'f']
3333

3434
it "should trimLeft all lines when trimLeft is true", ->
35-
S('abc def').splitIn(3, yes).should.be.like ['abc', 'def']
35+
new S('abc def').splitIn(3, yes).should.be.like ['abc', 'def']
3636

3737
describe 'cut()', ->
3838
it "should work correctly with text containing tabs and tags", ->
39-
original = S("12\t3<hello>456")
39+
original = new S("12\t3<hello>456")
4040
cut = original.cut(2, 3)
4141
original.str.should.equal '123<hello>456'
4242
cut.str.should.equal '\t'
4343

4444
it "should trim left when trimLeft is true", ->
45-
original = S ' 132'
45+
original = new S ' 132'
4646
cut = original.cut 0, 1, yes
4747
original.str.should.equal '32'
4848
cut.str.should.equal '1'
4949

5050
it "should be greedy", ->
51-
S("ab<tag>a").cut(0, 2).str.should.equal "ab<tag>"
51+
new S("ab<tag>a").cut(0, 2).str.should.equal "ab<tag>"
5252

5353
describe 'isOnlySpecialChars()', ->
5454
it "should work", ->
55-
S("12\t3<hello>456").isOnlySpecialChars().should.equal no
56-
S("<hello>").isOnlySpecialChars().should.equal yes
55+
new S("12\t3<hello>456").isOnlySpecialChars().should.equal no
56+
new S("<hello>").isOnlySpecialChars().should.equal yes
5757

5858
describe 'clone()', ->
5959
it "should return independent instance", ->
60-
a = S('hello')
60+
a = new S('hello')
6161
b = a.clone()
6262
a.str.should.equal b.str
6363
a.should.not.equal b
6464

6565
describe 'trim()', ->
6666
it "should return an independent instance", ->
67-
s = S('')
67+
s = new S('')
6868
s.trim().should.not.equal s
6969

7070
it 'should return the same string when trim is not required', ->
71-
S('hello').trim().str.should.equal 'hello'
71+
new S('hello').trim().str.should.equal 'hello'
7272

7373
it 'should return trimmed string', ->
74-
S(' hello').trim().str.should.equal 'hello'
74+
new S(' hello').trim().str.should.equal 'hello'
7575

7676
describe 'trimLeft()', ->
7777
it "should only trim on the left", ->
78-
S(' hello ').trimLeft().str.should.equal 'hello '
78+
new S(' hello ').trimLeft().str.should.equal 'hello '
7979

8080
describe 'trimRight()', ->
8181
it "should only trim on the right", ->
82-
S(' hello ').trimRight().str.should.equal ' hello'
82+
new S(' hello ').trimRight().str.should.equal ' hello'

0 commit comments

Comments
 (0)
Please sign in to comment.