Skip to content

Commit

Permalink
fix(devkit): remove from package-json should pass when dev dependenci…
Browse files Browse the repository at this point in the history
…es null

Closes nrwl#9877
  • Loading branch information
AgentEnder committed Apr 20, 2022
1 parent a1326ae commit 6ec149f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/devkit/src/utils/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,18 @@ export function removeDependenciesFromPackageJson(
};
}

function sortObjectByKeys(obj: unknown): unknown {
function sortObjectByKeys<T>(obj: T): T {
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
return obj;
}
return Object.keys(obj)
.sort()
.reduce((result, key) => {
return {
...result,
[key]: obj[key],
};
}, {});
}, {}) as T;
}

/**
Expand Down

0 comments on commit 6ec149f

Please sign in to comment.