chore: use package.mock.json for allowing non-existing npm deps in it
This commit is contained in:
parent
8ecfc31c0d
commit
2b3d2bd6a4
3 changed files with 9 additions and 3 deletions
|
|
@ -49,9 +49,16 @@ function getPackageJson(rootPath) {
|
||||||
const fileContent = fs.readFileSync(`${rootPath}/package.json`, 'utf8');
|
const fileContent = fs.readFileSync(`${rootPath}/package.json`, 'utf8');
|
||||||
return JSON.parse(fileContent);
|
return JSON.parse(fileContent);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
try {
|
||||||
|
// For testing purposes, we allow to have a package.mock.json that contains 'fictional'
|
||||||
|
// packages (like 'exporting-ref-project') not on npm registry
|
||||||
|
const fileContent = fs.readFileSync(`${rootPath}/package.mock.json`, 'utf8');
|
||||||
|
return JSON.parse(fileContent);
|
||||||
|
} catch (__) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {PathFromSystemRoot} rootPath
|
* @param {PathFromSystemRoot} rootPath
|
||||||
|
|
@ -252,8 +259,7 @@ class InputDataService {
|
||||||
const project = { path: projectPath };
|
const project = { path: projectPath };
|
||||||
// Add project meta info
|
// Add project meta info
|
||||||
try {
|
try {
|
||||||
const file = pathLib.resolve(projectPath, 'package.json');
|
const pkgJson = getPackageJson(projectPath);
|
||||||
const pkgJson = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
project.mainEntry = this.__normalizeMainEntry(pkgJson.main || './index.js');
|
project.mainEntry = this.__normalizeMainEntry(pkgJson.main || './index.js');
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue