octokit-plugin-create-symlink
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

octokit-plugin-create-symlink

Octokit plugin to create a symlink to a file within the same repository

@latest Build Status

usage

Browsers

Load octokit-plugin-create-symlink and @octokit/core (or core-compatible module) directly from cdn.skypack.dev

<script type="module">
  import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
  import {
    createSymlink,
    composeCreateSymlink,
  } from "https://cdn.skypack.dev/octokit-plugin-create-symlink";
</script>

Node

Install with npm install @octokit/core octokit-plugin-create-symlink. Optionally replace @octokit/core with a compatible module

const { Octokit } = require("@octokit/core");
const {
  createSymlink,
  composeCreateSymlink,
} = require("octokit-plugin-create-symlink");

This plugin creates or updates a file (source) as a symlink which points to another file (target). It does not check whether the source or target file exists. If there is no change, an empty commit is created.

Use as plugin

const MyOctokit = Octokit.plugin(createSymlink);
const octokit = new MyOctokit({ auth: "secret123" });

// the symlink file that will be created or updated
const sourcePath = "folder-with-symlinked-readme/README.md";

// path to the existing file or directory, relative from `sourcePath`.
const targetPath = "../README.md";

const { commit } = await octokit.createSymlink({
  owner: "gr2m",
  repo: "octokit-plugin-create-symlink",
  sourcePath,
  targetPath,
  message: `Link ${sourcePath}`,
});

console.log("Symlink created via %s", commit.html_url);

Standalone

When using the composeCreateSymlink function, pass the octokit instance as first argument.

const { commit } = await composeCreateSymlink(octokit, {
  owner: "gr2m",
  repo: "octokit-plugin-create-symlink",
  sourcePath,
  targetPath,
  message: `Link ${targetPath} to ${targetPath}`,
});
console.log("Symlink created via %s", commit.html_url);

Options

name type description
owner string Required. Repository owner login
repo string Required. Repository name
sourcePath string Required. The symlink file that will be created or updated
targetPath string Required. Path to the existing file or directory, relative from `sourcePath`.
message string Required. Commit message
branch string Branch name to commit to. Defaults to the repository's default branch.

Contributing

See CONTRIBUTING.md

License

MIT

Dependents (0)

Package Sidebar

Install

npm i octokit-plugin-create-symlink

Weekly Downloads

8

Version

1.0.3

License

MIT

Unpacked Size

28.3 kB

Total Files

13

Last publish

Collaborators

  • gr2m