Skip to content

Commit

Permalink
fix: missing scripts section (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha authored Nov 22, 2024
1 parent c6a773f commit 3cbe7da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/package_json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Deno.test("single entrypoint", () => {
devDependencies: {
"@types/node": versions.nodeTypes,
},
scripts: undefined,
scripts: {},
exports: {
".": {
import: {
Expand Down Expand Up @@ -137,7 +137,7 @@ Deno.test("single entrypoint", () => {
devDependencies: {
"@types/node": versions.nodeTypes,
},
scripts: undefined,
scripts: {},
exports: {
".": {
import: {
Expand Down Expand Up @@ -169,7 +169,7 @@ Deno.test("single entrypoint", () => {
devDependencies: {
"@types/node": versions.nodeTypes,
},
scripts: undefined,
scripts: {},
_generatedBy: "dnt@dev",
},
);
Expand All @@ -193,7 +193,7 @@ Deno.test("single entrypoint", () => {
devDependencies: {
"@types/node": versions.nodeTypes,
},
scripts: undefined,
scripts: {},
exports: {
".": {
import: "./esm/mod.js",
Expand Down Expand Up @@ -226,7 +226,7 @@ Deno.test("single entrypoint", () => {
devDependencies: {
"@types/node": versions.nodeTypes,
},
scripts: undefined,
scripts: {},
exports: {
".": {
import: "./esm/mod.js",
Expand Down Expand Up @@ -353,7 +353,7 @@ Deno.test("multiple entrypoints", () => {
},
},
},
scripts: undefined,
scripts: {},
_generatedBy: "dnt@dev",
});
});
Expand Down Expand Up @@ -423,7 +423,7 @@ Deno.test("binary entrypoints", () => {
},
},
},
scripts: undefined,
scripts: {},
_generatedBy: "dnt@dev",
});
});
Expand Down
3 changes: 2 additions & 1 deletion lib/package_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function getPackageJson({
// override with specified scripts
...(packageJsonObj.scripts ?? {}),
})
: packageJsonObj.scripts;
: packageJsonObj.scripts ?? {};
const mainExport = exports.length > 0
? {
module: includeEsModule ? `./esm/${exports[0].path}` : undefined,
Expand All @@ -112,6 +112,7 @@ export function getPackageJson({
...mainExport,
...binaryExport,
...packageJsonObj,
scripts: {},
...deleteEmptyKeys({
exports: {
...(includeEsModule || exports.length > 1
Expand Down
1 change: 1 addition & 0 deletions tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ Deno.test("should build with all options off", async () => {
devDependencies: {
"@types/node": versions.nodeTypes,
},
scripts: {},
_generatedBy: "dnt@dev",
});

Expand Down

0 comments on commit 3cbe7da

Please sign in to comment.