Speed up test suite by using local npm.js stub

This commit is contained in:
Michael Jackson
2019-08-01 18:01:12 -07:00
parent f362fa9717
commit c3dc2dd014
16 changed files with 89 additions and 71 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,33 @@
import fs from 'fs';
import path from 'path';
function getPackageInfo(packageName) {
const file = path.resolve(__dirname, `./metadata/${packageName}.json`);
try {
return JSON.parse(fs.readFileSync(file, 'utf-8'));
} catch (error) {
return null;
}
}
export function getVersionsAndTags(packageName) {
const info = getPackageInfo(packageName);
return info
? { versions: Object.keys(info.versions), tags: info['dist-tags'] }
: [];
}
export function getPackageConfig(packageName, version) {
const info = getPackageInfo(packageName);
return info ? info.versions[version] : null;
}
export function getPackage(packageName, version) {
const file = path.resolve(
__dirname,
`./packages/${packageName}-${version}.tgz`
);
return fs.existsSync(file) ? fs.createReadStream(file) : null;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.