Skip to content

Commit 3e241de

Browse files
committed
fix: don't modify other fields
1 parent d3254f2 commit 3e241de

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

dist/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15167,8 +15167,10 @@ var getGitHubContributors = async (token) => {
1516715167
const contributors = await Promise.all(contributorList.filter(({ type }) => type === "User").map((user) => octokit.request("GET /users/{username}", { username: user.login }).then(({ data }) => data)));
1516815168
return contributors;
1516915169
};
15170-
var updatePackageJson = async (packageJson) => {
15171-
await import_fs.promises.writeFile("package.json", JSON.stringify(packageJson, null, 2), "utf-8");
15170+
var updatePackageJson = async (contributors) => {
15171+
const jsonFile = JSON.parse(await import_fs.promises.readFile("package.json", "utf8"));
15172+
jsonFile.contributors = contributors;
15173+
await import_fs.promises.writeFile("package.json", JSON.stringify(jsonFile, null, 2), "utf-8");
1517215174
};
1517315175
var updateContributors = async (token) => {
1517415176
const [mailList, packageJson, contributors] = await Promise.all([
@@ -15186,7 +15188,7 @@ var updateContributors = async (token) => {
1518615188
}
1518715189
return createContributorString({ name: fullName, email, url });
1518815190
});
15189-
return updatePackageJson({ ...packageJson, contributors: newContributors });
15191+
return updatePackageJson(newContributors);
1519015192
};
1519115193

1519215194
// src/main.ts

src/update.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ const getGitHubContributors = async (token: string) => {
8181
return contributors
8282
}
8383

84-
const updatePackageJson = async (packageJson: readPackage.NormalizedPackageJson) => {
85-
await fs.writeFile('package.json', JSON.stringify(packageJson, null, 2), 'utf-8')
84+
const updatePackageJson = async (contributors: string[]) => {
85+
// eslint-disable-next-line unicorn/prefer-json-parse-buffer
86+
const jsonFile = JSON.parse(await fs.readFile('package.json', 'utf8'))
87+
jsonFile.contributors = contributors
88+
await fs.writeFile('package.json', JSON.stringify(jsonFile, null, 2), 'utf-8')
8689
}
8790

8891
export const updateContributors = async (token: string) => {
@@ -108,5 +111,5 @@ export const updateContributors = async (token: string) => {
108111
return createContributorString({ name: fullName, email, url })
109112
})
110113

111-
return updatePackageJson({ ...packageJson, contributors: newContributors })
114+
return updatePackageJson(newContributors)
112115
}

0 commit comments

Comments
 (0)