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: dont override set pkg.json props #4017

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: dont override set pkg.json props
Signed-off-by: Even Stensberg <evenstensberg@gmail.com>
  • Loading branch information
evenstensberg authored and alexander-akait committed Jan 19, 2024
commit 11ee0d49770191001d5c9111787a3efa3873d567
21 changes: 16 additions & 5 deletions packages/generators/src/handlers/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,22 @@ export async function questions(
* @param self Generator values
*/
export function generate(self: CustomGenerator): void {
self.fs.extendJSON(
self.destinationPath("package.json"),
// eslint-disable-next-line @typescript-eslint/no-var-requires
require(resolveFile("package.json.js"))(self.answers.devServer),
);
// eslint-disable-next-line @typescript-eslint/no-var-requires
const destPkgJson = require(resolveFile("package.json.js"))(self.answers.devServer);
const sourcePkgJsonPath = self.destinationPath("package.json");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sourcePkgJson = require(sourcePkgJsonPath);
// Make sure that we do not override set metadata
if (sourcePkgJson.name) {
delete destPkgJson.name;
}
if (sourcePkgJson.description) {
delete destPkgJson.description;
}
if (sourcePkgJson.version) {
delete destPkgJson.version;
}
self.fs.extendJSON(sourcePkgJsonPath, destPkgJson);

// Generate entry file
let entry = "./src/index.";
Expand Down