๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
DemoInstallSign in
Socket

github-publish

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-publish

Publishes a file to a repository through the GitHub Contents API

6.0.0
latest
Source
npm
Version published
Weekly downloads
171
76.29%
Maintainers
0
Weekly downloads
ย 
Created
Source

GitHub Publish

npm version npm downloads Module type: ESM Types in JS neostandard javascript style Follow @voxpelli@mastodon.social

Publishes a file to a repository through the GitHub Contents API

Installation

NPM

npm install github-publish

Current status

Stable, but not feature complete

Currently missing support for deletes.

Usage

import { GitHubPublisher } from 'github-publish';

const publisher = new GitHubPublisher('token123', 'voxpelli', 'voxpelli.github.com');

const result = await publisher.publish('_post/2015-07-17-example-post.md', 'file content');

// If "result" is truthy then the post was successfully published

Classes

  • GitHubPublisher(token, username, repo, [branch]) โ€“ creates a publisher object with an access token for the GitHub API, the username of the owner of the repository to publish to and the name of the repository itself as repo.

GitHubPublisher methods

  • retrieve(filename) โ€“ returns a Promise that resolves with either an object containing the content and sha of the existing file or with false if no such file exists in the repository
  • publish(filename, content, [options]) โ€“ publishes the specified content as the filename to the repo of the publisher object. content should be either a string or a Buffer. Returns a Promise which resolves to the sha of the created object on success and to false on failure (failure is likely caused by a collision with a pre-existing file, as long as one haven't specified that it should be overridden).

publish() options

  • force โ€“ whether to replace any pre-existing file no matter what
  • message โ€“ a custom commit message. Default is new content
  • sha โ€“ the sha of an existing file that one wants to replace

FAQs

Package last updated on 25 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts