Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
export const fsWrapper = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
mkdirpAsync: promisify(mkdirp),
doesPathExistSync: fs.existsSync,
rmdirSync: fs.rmdirSync,
removeFileAsync: promisify(fs.unlink),
statAsync: promisify(fs.stat),
appendFileAsync: promisify(fs.appendFile),
accessAsync: promisify(fs.access),
doesFileExistAsync: async (filePath: string): Promise => {
try {
await fsWrapper.accessAsync(
filePath,
// node says we need to use bitwise, but tslint says no:
fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
);
} catch (err) {
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
export const fsWrapper = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
mkdirpAsync: promisify(mkdirp),
doesPathExistSync: fs.existsSync,
rmdirSync: fs.rmdirSync,
removeFileAsync: promisify(fs.unlink),
statAsync: promisify(fs.stat),
appendFileAsync: promisify(fs.appendFile),
accessAsync: promisify(fs.access),
doesFileExistAsync: async (filePath: string): Promise => {
try {
await fsWrapper.accessAsync(
filePath,
// node says we need to use bitwise, but tslint says no:
fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
);
} catch (err) {
return false;
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
export const fsWrapper = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
mkdirpAsync: promisify(mkdirp),
doesPathExistSync: fs.existsSync,
rmdirSync: fs.rmdirSync,
removeFileAsync: promisify(fs.unlink),
statAsync: promisify(fs.stat),
appendFileAsync: promisify(fs.appendFile),
accessAsync: promisify(fs.access),
doesFileExistAsync: async (filePath: string): Promise => {
try {
await fsWrapper.accessAsync(
filePath,
// node says we need to use bitwise, but tslint says no:
fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
);
} catch (err) {
return false;
}
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
export const fsWrapper = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
mkdirpAsync: promisify(mkdirp),
doesPathExistSync: fs.existsSync,
rmdirSync: fs.rmdirSync,
removeFileAsync: promisify(fs.unlink),
statAsync: promisify(fs.stat),
appendFileAsync: promisify(fs.appendFile),
accessAsync: promisify(fs.access),
doesFileExistAsync: async (filePath: string): Promise => {
try {
await fsWrapper.accessAsync(
filePath,
// node says we need to use bitwise, but tslint says no:
fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
);
} catch (err) {
return false;
}
return true;
},
};
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
export const fsWrapper = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
mkdirpAsync: promisify(mkdirp),
doesPathExistSync: fs.existsSync,
rmdirSync: fs.rmdirSync,
removeFileAsync: promisify(fs.unlink),
statAsync: promisify(fs.stat),
appendFileAsync: promisify(fs.appendFile),
accessAsync: promisify(fs.access),
doesFileExistAsync: async (filePath: string): Promise => {
try {
await fsWrapper.accessAsync(
filePath,
// node says we need to use bitwise, but tslint says no:
fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
);
} catch (err) {
return false;
}
return true;
},
};
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
export const fsWrapper = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
mkdirpAsync: promisify(mkdirp),
doesPathExistSync: fs.existsSync,
rmdirSync: fs.rmdirSync,
removeFileAsync: promisify(fs.unlink),
statAsync: promisify(fs.stat),
appendFileAsync: promisify(fs.appendFile),
accessAsync: promisify(fs.access),
doesFileExistAsync: async (filePath: string): Promise => {
try {
await fsWrapper.accessAsync(
filePath,
// node says we need to use bitwise, but tslint says no:
fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
);
} catch (err) {
return false;
}
return true;
},
};
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
export const fsWrapper = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
mkdirpAsync: promisify(mkdirp),
doesPathExistSync: fs.existsSync,
rmdirSync: fs.rmdirSync,
removeFileAsync: promisify(fs.unlink),
statAsync: promisify(fs.stat),
appendFileAsync: promisify(fs.appendFile),
accessAsync: promisify(fs.access),
doesFileExistAsync: async (filePath: string): Promise => {
try {
await fsWrapper.accessAsync(
filePath,
// node says we need to use bitwise, but tslint says no:
fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
);
} catch (err) {
return false;
}
return true;
},
};
public async sendRawPayloadAsync<a>(payload: Partial): Promise</a><a> {
const sendAsync = this._provider.sendAsync.bind(this._provider);
const payloadWithDefaults = {
id: this._jsonRpcRequestId++,
params: [],
jsonrpc: '2.0',
...payload,
};
const response = await promisify(sendAsync)(payloadWithDefaults);
if (response.error) {
throw new Error(response.error.message);
}
const result = response.result;
return result;
}
/**</a>
import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter';
import { constants } from './constants';
import { parseSourceMap } from './source_maps';
import {
ContractData,
Coverage,
SourceRange,
Subtrace,
TraceInfo,
TraceInfoExistingContract,
TraceInfoNewContract,
} from './types';
import { utils } from './utils';
const mkdirpAsync = promisify(mkdirp);
export type SingleFileSubtraceHandler = (
contractData: ContractData,
subtrace: Subtrace,
pcToSourceRange: { [programCounter: number]: SourceRange },
fileIndex: number,
) => Coverage;
/**
* TraceCollector is used by CoverageSubprovider to compute code coverage based on collected trace data.
*/
export class TraceCollector {
private readonly _artifactAdapter: AbstractArtifactAdapter;
private readonly _logger: Logger;
private _contractsData!: ContractData[];
private readonly _collector = new Collector();