Skip to content

Commit

Permalink
Fixed resolving monorepo packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dlvoy committed Nov 14, 2023
1 parent e1518bd commit 0ea030f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-license-gen",
"version": "1.1.0",
"version": "1.1.1",
"description": "Generate HTML with license text from NPM/Yarn dependencies",
"bin": {
"html-license-gen": "./build/html-license-gen"
Expand Down
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ async function getPkgLicense(pkg: PkgInfo): Promise<LicenseInfo> {
let hasLicenseInfo = false;

if (AVOID_REGISTRY) {
const packageLocalFile = path.resolve(CWD, pkg.localPackageFile);

hasLicenseInfo = await new Promise<boolean>((resolve) => {
if (fs.existsSync(packageLocalFile)) {
const packageLocalFile = findInRepos(pkg.localPackageFile);
if (packageLocalFile) {
logger.debug(`Loading package.json from ${pkg.localPackageFile} resolved ${packageLocalFile} for ${pkg.name}`);
const pkgPayload = fs.readFileSync(packageLocalFile, 'utf8');
const pkgInfo: PkgJsonData = JSON.parse(pkgPayload);
Expand All @@ -138,7 +137,7 @@ async function getPkgLicense(pkg: PkgInfo): Promise<LicenseInfo> {
}
resolve(true);
} else {
logger.error(`Cannot parse local package: ${pkg.localPackageFile}`);
logger.verbose(`Cannot find local package: ${pkg.localPackageFile}`);
resolve(false);
}
});
Expand Down Expand Up @@ -574,7 +573,7 @@ async function main(): Promise<void> {

if (CHECKSUM_EMBED !== false) {
if (fs.existsSync(OUT_PATH)) {
logger.debug(`Found previously generated HTML file: ${OUT_PATH}`)
logger.debug(`Found previously generated HTML file: ${OUT_PATH}`);
const oldHtml = fs.readFileSync(OUT_PATH, 'utf8');
if (oldHtml.includes(`[[checksum: ${versionCorpusHash}]]`)) {
logger.info('Generating license HTML skipped');
Expand Down Expand Up @@ -702,7 +701,7 @@ async function main(): Promise<void> {
}

if (!KEEP_CACHE) {
logger.debug(`Deleting cache from: ${TMP_FOLDER_PATH}`)
logger.debug(`Deleting cache from: ${TMP_FOLDER_PATH}`);
rimraf.sync(TMP_FOLDER_PATH);
}
logger.info('Done!');
Expand Down

0 comments on commit 0ea030f

Please sign in to comment.