in src/audit-license-headers.js [94:114]
async function getRatJar () {
const RAT_ID = 'apache-rat-0.12';
const RAT_URL = `https://archive.apache.org/dist/creadur/${RAT_ID}/${RAT_ID}-bin.tar.gz`;
const cohoRoot = path.resolve(__dirname, '..');
const ratJarPath = path.join(cohoRoot, RAT_ID, RAT_ID + '.jar');
if (!fs.existsSync(ratJarPath)) {
console.log('RAT tool not found, downloading to: ' + ratJarPath);
const unzip = new DecompressionStream('gzip');
await fetch(RAT_URL)
.then((resp) => resp.body.pipeThrough(unzip))
.then((stream) => Readable.fromWeb(stream))
.then((stream) => pipeline(stream, tar.extract(cohoRoot)))
.catch(err => {
throw new Error('Failed to get RAT JAR:\n' + err.message);
});
}
return ratJarPath;
}