Skip to content

Commit

Permalink
Add check before log in moonbeam decorator (#899)
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Viola <javier@parity.io>
  • Loading branch information
wirednkod and pepoviola authored Apr 5, 2023
1 parent 0341520 commit 9e99134
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2,618 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ async function addAuthority(specPath: string, node: Node, key: GenesisNodeKey) {
],
]);

new CreateLogTable({
colWidths: [120],
}).pushToPrint([chainSpec.genesis.runtime.authorMapping]);
chainSpec?.genesis?.runtime?.authorMapping?.mappings &&
new CreateLogTable({
colWidths: [20, 50, 50],
}).pushToPrint(
chainSpec.genesis.runtime.authorMapping.mappings.map((map: string[]) => [
decorators.cyan("mapping"),
...map,
]),
);

writeChainSpec(specPath, chainSpec);
}
Expand Down
34 changes: 18 additions & 16 deletions javascript/packages/utils/src/tableCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,26 @@ export class CreateLogTable {
}

pushTo = (inputs: any[][]) => {
inputs.forEach((input) => {
input.forEach((inp, index) => {
const split = this.colWidths[index] - 10;
const times = parseInt((inp.length / split).toString());
if (times > 1) {
let some = inp;
for (let i = 0; i <= times; i++) {
if (i === 0) {
inp = some.substring(0, split);
} else {
inp += "\n" + some.substring(split * i, split * (i + 1));
Array.isArray(inputs) &&
inputs.forEach((input) => {
Array.isArray(input) &&
input.forEach((inp, index) => {
const split = this.colWidths[index] - 10;
const times = parseInt((inp.length / split).toString());
if (times > 1) {
let some = inp;
for (let i = 0; i <= times; i++) {
if (i === 0) {
inp = some.substring(0, split);
} else {
inp += "\n" + some.substring(split * i, split * (i + 1));
}
}
input[index] = inp;
}
}
input[index] = inp;
}
});
this.table!.push(input);
});
this.table!.push(input);
});
};

print = () => {
Expand Down
Loading

0 comments on commit 9e99134

Please sign in to comment.