korefile
korefile: コレ・ファイル
File System API for Local/GitHub.
Features
- Write/Read/Delete API for Local/GitHub
- Pluggable adaptor
Install
Install with npm:
npm install korefile
Usage
Korefile apply KoreFileAdaptor implementation.
FsAdaptor
Read/Write/Delete for local file system.
It wraps fs
module.
import {createKoreFile, createFsAdaptor} from "korefile";
const koreFile = createKoreFile({
adaptor: createFsAdaptor()
});
(async () => {
await koreFile.writeFile("/path/to/file", "content");
const content = await koreFile.readFile("/path/to/file");
await koreFile.deleteFile("/path/to/file");
})()
GitHubAdaptor
Read/Write/Delete for GitHub repository.
It wrap octokit/rest.js.
Require GitHub Auth Token.
import {createKoreFile, createGitHubAdaptor} from "korefile";
const koreFile = createKoreFile({
adaptor: createGitHubAdaptor({
owner: "azu",
repo: "korefile",
ref: "heads/test",
token: process.env.GH_TOKEN
})
});
(async () => {
const testFilePath = "file.test";
await koreFile.writeFile(testFilePath, input);
const content = await koreFile.readFile(testFilePath);
await koreFile.deleteFile(testFilePath);
})();
UseCase
Changelog
See Releases page.
Running tests
Install devDependencies and Run npm test
:
npm test
Contributing
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
License
MIT © azu