Update dependency p-limit to v6 (#5104)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: cairo <cairoeth@protonmail.com>
This commit is contained in:
renovate[bot]
2024-10-29 10:25:02 +01:00
committed by GitHub
parent f96237308f
commit 3da7a869aa
3 changed files with 125 additions and 28 deletions

View File

@ -7,11 +7,16 @@
// node certora/run.js AccessControl
// node certora/run.js AccessControlHarness:AccessControl
const proc = require('child_process');
const { PassThrough } = require('stream');
const events = require('events');
import { spawn } from 'child_process';
import { PassThrough } from 'stream';
import { once } from 'events';
import path from 'path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import pLimit from 'p-limit';
import fs from 'fs/promises';
const argv = require('yargs')
const argv = yargs(hideBin(process.argv))
.env('')
.options({
all: {
@ -21,7 +26,7 @@ const argv = require('yargs')
spec: {
alias: 's',
type: 'string',
default: __dirname + '/specs.json',
default: path.resolve(import.meta.dirname, 'specs.json'),
},
parallel: {
alias: 'p',
@ -38,18 +43,20 @@ const argv = require('yargs')
type: 'array',
default: [],
},
}).argv;
})
.parse();
function match(entry, request) {
const [reqSpec, reqContract] = request.split(':').reverse();
return entry.spec == reqSpec && (!reqContract || entry.contract == reqContract);
}
const specs = require(argv.spec).filter(s => argv.all || argv._.some(r => match(s, r)));
const limit = require('p-limit')(argv.parallel);
const specs = JSON.parse(fs.readFileSync(argv.spec, 'utf8')).filter(s => argv.all || argv._.some(r => match(s, r)));
const limit = pLimit(argv.parallel);
if (argv._.length == 0 && !argv.all) {
console.error(`Warning: No specs requested. Did you forgot to toggle '--all'?`);
console.error(`Warning: No specs requested. Did you forget to toggle '--all'?`);
}
for (const r of argv._) {
@ -64,12 +71,13 @@ if (process.exitCode) {
}
for (const { spec, contract, files, options = [] } of specs) {
limit(
runCertora,
spec,
contract,
files,
[...options, ...argv.options].flatMap(opt => opt.split(' ')),
limit(() =>
runCertora(
spec,
contract,
files,
[...options, ...argv.options].flatMap(opt => opt.split(' ')),
),
);
}
@ -79,7 +87,7 @@ async function runCertora(spec, contract, files, options = []) {
if (argv.verbose) {
console.log('Running:', args.join(' '));
}
const child = proc.spawn('certoraRun', args);
const child = spawn('certoraRun', args);
const stream = new PassThrough();
const output = collect(stream);
@ -103,7 +111,7 @@ async function runCertora(spec, contract, files, options = []) {
});
// wait for process end
const [code, signal] = await events.once(child, 'exit');
const [code, signal] = await once(child, 'exit');
// error
if (code || signal) {