catto.js 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/GitHub.js +9 -5
  2. package/package.json +1 -1
package/GitHub.js CHANGED
@@ -24,6 +24,7 @@ class GitHub {
24
24
  "repository": "",
25
25
  "message": "cattojs"
26
26
  }, options || {});
27
+ this.sha = null;
27
28
  }
28
29
  /**
29
30
  * Reads data from a file in the Github repository.
@@ -36,13 +37,15 @@ class GitHub {
36
37
  * @throws {Error} If there is a problem with the API request.
37
38
  */
38
39
  async read(file) {
39
- var value = Base64.decode((await request.get({
40
+ var value = (await request.get({
40
41
  "url": `https://api.github.com/repos/${this.options.username}/${this.options.repository}/contents/${file}`,
41
42
  "headers": {
42
43
  "User-Agent": this.options.username,
43
44
  "Authorization": `token ${this.options.token}`
44
45
  }
45
- })).body.content);
46
+ })).body;
47
+ this.sha = value.sha;
48
+ value = Base64.decode(value.content);
46
49
  try {
47
50
  value = JSON.parse(value);
48
51
  } catch(e) {}
@@ -63,7 +66,7 @@ class GitHub {
63
66
  if (typeof value === "object") {
64
67
  value = JSON.stringify(value);
65
68
  }
66
- await request.put({
69
+ this.sha = (await request.put({
67
70
  "url": `https://api.github.com/repos/${this.options.username}/${this.options.repository}/contents/${file}`,
68
71
  "headers": {
69
72
  "User-Agent": this.options.username,
@@ -72,9 +75,10 @@ class GitHub {
72
75
  "json": !0,
73
76
  "body": {
74
77
  "content": Base64.encode(value),
75
- "message": this.options.message
78
+ "message": this.options.message,
79
+ "sha": this.sha
76
80
  }
77
- });
81
+ })).body.content.sha;
78
82
  return !0;
79
83
  }
80
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catto.js",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Universal module for everything.",
5
5
  "main": "index.js",
6
6
  "scripts": {