Skip to content

Commit 49f5acf

Browse files
authored
Merge pull request #20 from jacklehamster/master
Allow setting data as raw strings
2 parents bac4cfe + 38e2d3c commit 49f5acf

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/out/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@the-brains/github-db",
3-
"version": "1.0.18",
3+
"version": "1.0.19",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/the-brains/GithubDB.git"

src/github-api/github-api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,13 @@ export class GithubApi {
230230
const hasExtension = EXTENSION_REGEX.test(key);
231231
const path = `contents/data/${key}${hasExtension ? "" : ".json"}`;
232232
const isBlob = value instanceof Blob;
233-
const content = value === null ? null : isBlob ? await this.makeBase64Blob(value) : btoa(JSON.stringify(value, null, 2));
233+
const isRawText = typeof value === "string";
234+
const content = value === null ? null : isBlob ? await this.makeBase64Blob(value) : btoa(isRawText ? value : JSON.stringify(value, null, 2));
234235
const url = `${this.rootURL}/repos/${organizationName}/${databaseStorageRepoName}/${path}`;
235236

236237
const newData = JSON.stringify({
237238
message: `Creating key/value for key: '${key}'`,
238-
content: content,
239+
content,
239240
sha: data.sha,
240241
branch: options?.branch,
241242
committer: options?.committer ?? {

0 commit comments

Comments
 (0)