Skip to content

Commit eb5bb56

Browse files
authored
ci: fix node-versions run for node <16 (#1653)
* re-add updating to npm v7 for node versions <16 * only upgrade npm for node v <16 * fix bin/rlp js: node 12 doesn't support ES11 which added support for nullish coalescing operator (??) so we'll use ternary here alternatively we could write this file in TS and compile to e.g. dist/bin/rlp (like we do in the client bin), but maybe if the file gets more complicated, in its current state i don't think it's so neccessary * use same errorMsg format for JSON.parse, remove unneeded extra Uint8Array.from (already is uint8array)
1 parent 476039a commit eb5bb56

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.github/workflows/node-versions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ jobs:
4040
node-version: ${{ matrix.node }}
4141
cache: 'npm'
4242

43+
- name: Use npm v7 for workspaces support
44+
run: npm i -g npm@7
45+
if: ${{ matrix.node-version < 16 }}
46+
4347
- run: npm i
4448

4549
- name: Test Block

packages/rlp/bin/rlp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ if (method === 'encode') {
1616
try {
1717
json = JSON.parse(strInput)
1818
} catch (error) {
19-
return console.error(`Error could not parse JSON: ${JSON.stringify(error)}`)
19+
const errorMsg = error.message ? error.message : error
20+
return console.error(`Error could not parse JSON: ${errorMsg}`)
2021
}
2122

2223
// Encode RLP
2324
try {
2425
const encoded = RLP.encode(json)
25-
console.log('0x' + bytesToHex(Uint8Array.from(encoded)))
26+
console.log('0x' + bytesToHex(encoded))
2627
} catch (error) {
27-
console.error(`Error encoding RLP: ${error.message ?? error}`)
28+
const errorMsg = error.message ? error.message : error
29+
console.error(`Error encoding RLP: ${errorMsg}`)
2830
}
2931
} else if (method === 'decode') {
3032
// Decode
@@ -33,7 +35,8 @@ if (method === 'encode') {
3335
const json = JSON.stringify(arrToJSON(decoded))
3436
console.log(json)
3537
} catch (error) {
36-
console.error(`Error decoding RLP: ${error.message ?? error}`)
38+
const errorMsg = error.message ? error.message : error
39+
console.error(`Error decoding RLP: ${errorMsg}`)
3740
}
3841
} else {
3942
console.error('Unsupported method')

0 commit comments

Comments
 (0)