-
Notifications
You must be signed in to change notification settings - Fork 0
/
runWithoutWarnings.ts
36 lines (34 loc) · 1.41 KB
/
runWithoutWarnings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { spawn } from 'child_process';
import chalk from 'chalk';
const forbiddenRegexps = [
/Unable to find handler for subscription/,
/Unable to find active subscription/,
/has multiple versions, ensure that there is only one installed/,
/Either remove and explicitly install matching versions or dedupe using your package manager/,
/The following conflicting packages were found/,
/cjs \d[.]\d[.]\d/,
/API-WS: disconnected from ws/,
/disconnected from ws:\/\/127.0.0.1:9944: 1000:: Normal connection closure/,
/CONTRACT: Unable to decode contract event: createType\(AccountId\):: Invalid AccountId provided, expected 32 bytes, found 18/, // event decoding fails and that is an artifact of it
];
(async () => {
if (require.main !== module) return;
const cliArgs = process.argv.slice(2);
const command = cliArgs[0];
const args = cliArgs.slice(1);
console.log(`Executing command ` + chalk.green(`${command} ${args.join(' ')} `) + `with surpressed warnings!`);
const p = spawn(command, args, { stdio: ['inherit', 'inherit', 'pipe'] });
p.stderr?.on('data', (data) => {
if (forbiddenRegexps.every((reg) => !data.toString().match(reg))) console.log(data.toString());
});
p.on('exit', function (code) {
process.exit(code ?? 0);
});
p.on('error', function (err) {
throw err;
});
})().catch((e) => {
console.log(e);
console.error(chalk.red(JSON.stringify(e, null, 2)));
process.exit(1);
});