Skip to content

Commit aa58150

Browse files
committed
v1.1.3
1 parent 566aa9c commit aa58150

4 files changed

Lines changed: 18 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "acode-plugin-github",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Github plugin for acode editor",
55
"main": "dist/main.js",
66
"repository": "https://github.com/deadlyjack/acode-plugin-github.git",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "acode.plugin.github",
33
"name": "Github",
44
"main": "dist/main.js",
5-
"version": "1.1.2",
5+
"version": "1.1.3",
66
"readme": "readme.md",
77
"icon": "icon.png",
88
"files": [],

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Access your gist/repositories without cloning/downloading it. To access search `
1515
- **1.0.2**: Create/Delete file, directory in repository.
1616
- **1.0.3**: Bugs fixes.
1717
- **1.1.2**: Ask for commit message.
18+
- **1.1.3**: Updated to work with latest acode.

src/githubFs.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default function githubFs(token, settings) {
106106
const [repoName, branch] = repoAtBranch.split('@');
107107
let sha = '';
108108
const getSha = async () => {
109-
if (!sha) {
109+
if (!sha && path) {
110110
const res = await repo.getSha(branch, path);
111111
sha = res.data.sha;
112112
}
@@ -142,6 +142,7 @@ export default function githubFs(token, settings) {
142142
});
143143
},
144144
async readFile(encoding) {
145+
if (!path) throw new Error('Cannot read root directory')
145146
await init();
146147
await getSha();
147148
let { data } = await repo.getBlob(sha, 'blob');
@@ -154,6 +155,7 @@ export default function githubFs(token, settings) {
154155
return data;
155156
},
156157
async writeFile(data) {
158+
if (!path) throw new Error('Cannot write to root directory')
157159
const commitMessage = await getCommitMessage(`update ${path}`);
158160
await init();
159161
await repo.writeFile(branch, path, data, commitMessage);
@@ -201,25 +203,29 @@ export default function githubFs(token, settings) {
201203
throw new Error('Not implemented');
202204
},
203205
async delete() {
206+
if (!path) throw new Error('Cannot delete root');
204207
await init();
205208
await getSha();
206209
const commitMessage = await getCommitMessage(`delete ${path}`);
207210
await repo.deleteFile(branch, path, commitMessage, sha);
208211
},
209212
async moveTo(dest) {
213+
if (!path) throw new Error('Cannot move root');
210214
await init();
211215
const { path: destPath } = parseUrl(dest);
212216
const newName = Url.join(destPath, Url.basename(path));
213217
const res = await move(newName);
214218
return res;
215219
},
216220
async renameTo(name) {
221+
if (!path) throw new Error('Cannot rename root');
217222
await init();
218223
const newName = Url.join(Url.dirname(path), name);
219224
const res = await move(newName);
220225
return res;
221226
},
222227
async exists() {
228+
if (!path) return true;
223229
await init();
224230
try {
225231
await repo.getSha(branch, path);
@@ -229,6 +235,14 @@ export default function githubFs(token, settings) {
229235
}
230236
},
231237
async stat() {
238+
if (!path) {
239+
return {
240+
length: 0,
241+
name: `github/${user}/${repoName}`,
242+
isDirectory: true,
243+
isFile: false,
244+
}
245+
}
232246
await init();
233247
await getSha();
234248
const content = await repo.getBlob(sha);

0 commit comments

Comments
 (0)