Speed up test suite by using local npm.js stub
This commit is contained in:
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
@@ -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.
Reference in New Issue
Block a user