added commit messages for adding

This commit is contained in:
2024-05-23 11:52:59 -04:00
parent e0503b02c5
commit fdbf519f40
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -42,7 +42,7 @@ class ghelper {
} }
} }
async addToRepo(fpath, contentRaw, sha = undefined) { async addToRepo(fpath, contentRaw, sha = undefined, commit_message = undefined) {
try { try {
const url = `${this.ghurl}/contents/${fpath}`; const url = `${this.ghurl}/contents/${fpath}`;
@@ -50,7 +50,7 @@ class ghelper {
const toAdd = content.toString('base64'); const toAdd = content.toString('base64');
// Prepare the commit // Prepare the commit
const updateData = { const updateData = {
message: `added content for ${fpath}`, message: (commit_message) ? commit_message : `added content for ${fpath}`,
content: toAdd, content: toAdd,
}; };
@@ -233,17 +233,17 @@ export default class customFs {
* @param {{encoding:string}} opts? * @param {{encoding:string}} opts?
* @returns * @returns
*/ */
async writeFileSync(fPath, toWriteRaw, opts = undefined) { async writeFileSync(fPath, toWriteRaw, opts = undefined, commit_message = undefined) {
// { encoding: 'base64' } // { encoding: 'base64' }
const encoding = opts?.encoding; const encoding = opts?.encoding;
const toWrite = (encoding) ? Buffer.from(toWriteRaw).toString(encoding) : toWriteRaw; const toWrite = (encoding) ? Buffer.from(toWriteRaw).toString(encoding) : toWriteRaw;
const r = await this.existsSync(fPath); const r = await this.existsSync(fPath);
await wait(1000); await wait(1000);
return this.ghs.addToRepo(fPath, toWrite, r); return this.ghs.addToRepo(fPath, toWrite, r, commit_message);
} }
writeFile = (fName, toWrite, cb) => this.writeFileSync(fName, toWrite).then(() => cb()).catch(cb); writeFile = (fName, toWrite, cb, opts, commit_message = undefined) => this.writeFileSync(fName, toWrite, opts, commit_message).then(() => cb()).catch(cb);
readFileSync = async (fName) => this.ghs.getStructure(fName); readFileSync = async (fName) => this.ghs.getStructure(fName);
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "github-to-fs", "name": "github-to-fs",
"version": "1.0.4", "version": "1.0.5",
"description": "a package that allows you to use github like file storage", "description": "a package that allows you to use github like file storage",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {