1.0.3 • Published 4 years ago
octokit-plugin-create-symlink v1.0.3
octokit-plugin-create-symlink
Octokit plugin to create a symlink to a file within the same repository
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
Contributing
See CONTRIBUTING.md