Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js): check that project's package.json exists before attempting to read its contents #10650

Conversation

adriangroch
Copy link
Contributor

ISSUES CLOSED: #10649

Current Behavior

Building a node application using @nrwl/js:tsc as the executor without a package.json within the applications folder causes an error to be thrown as the executor attempts to read the contents file that does not exist.

Expected Behavior

An error is not thrown as we now check that the file exists before attempting to update it.

Related Issue(s)

Fixes #10649

@nx-cloud
Copy link

nx-cloud bot commented Jun 9, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 9efd349. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 12 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Jun 9, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
nx-dev ⬜️ Ignored (Inspect) Jun 9, 2022 at 11:09PM (UTC)

Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks for the contribution 🎉.

I left a few comments, after those are fixed we should be able to merge this.

packages/js/src/executors/tsc/tsc.impl.ts Outdated Show resolved Hide resolved
packages/js/src/executors/tsc/tsc.impl.ts Outdated Show resolved Hide resolved
Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @adriangroch! Sorry, I shouldn't have reviewed this so late at night evidently 😅. We should move the fileExists check inside of the updatePackageJson function s.t. the correct package.json still gets generated inside the dist folder.

I'd recommend moving it there, and doing something like:

const packageJson = fileExists(pathToPackageJson) ? readJson(pathToPackageJson) : {name: context.projectName}

This will also fix the same issue for @nrwl/js:swc.

@AgentEnder AgentEnder changed the title fix(js): check that package scoped package.json exists before attempting to read its contents fix(js): check that project's package.json exists before attempting to read its contents Jun 10, 2022
@AgentEnder AgentEnder merged commit a42d681 into nrwl:master Jun 10, 2022
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants