Skip to content

Commit

Permalink
fix(upgrade-task): Fixed upgrade task to include line ending in packa…
Browse files Browse the repository at this point in the history
…ge.json (#1650)

If the package manager is set to npm, the `npm install` command adds a new line to the end of package.json. This is a known issue: npm/npm#18545
All of the other tasks do not do this currently, and this causes the upgrade workflow to fail for the first time and self mutation fixes that. To avoid that, added this new line to package.json anyway.

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
AminFazlMondo authored Mar 4, 2022
1 parent 90f5546 commit 184b4e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/javascript/node-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,12 @@ export class NodePackage extends Component {
pkg.devDependencies = sorted(devDeps);
pkg.peerDependencies = sorted(peerDeps);

const updated = JSON.stringify(pkg, undefined, 2);
const jsonContent = JSON.stringify(pkg, undefined, 2);

const updated =
this.packageManager === NodePackageManager.NPM
? `${jsonContent}\n`
: jsonContent;

if (original === updated) {
return false;
Expand Down

0 comments on commit 184b4e2

Please sign in to comment.