Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including abswap with all npm packages installed. Try it out:

var abswap = require("abswap")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

abswap v2.2.6

Swap a/b directories or files using symlinks

abswap - Swap Files or Directories using Symlinks

dependencies  tests  npm  code size  license



  • Work with directories and regular files.
  • Maintain valid symlink for the activated selection (atomicity behavior).
  • Convert existing file or directory to a/b structure.


npm install --global abswapyarn global add abswap

CLI Usage

Usage: abswap [options] <path>

  -V, --version  output the version number
  --init         initialize a path for a/b swap
  --copy         copy existing path to inactive selection on initialize
  --file         expect (or create) regular files as targets
  --directory    expect (or create) directory as targets
  --undo         delete a/b structure and keep active selection
  --verify       verify a/b structure for consistence
  -h, --help     output usage information

Programmatic Usage

const { init, swap, undo } = require("abswap");

const PATH = "/tmp/example-path";

async function demo() {
  // Initialize a/b structure
  await init(PATH, { directory: true, copy: true });

  // Swap symlinks pointing to 'a' and 'b'.
  await swap(PATH);

  // Undo a/b structure and keep current selected directory.
  await undo(PATH);



  • New option --verify to check for a valid a/b structure.


  • Version is read asynchronously and only on demand from package.json.


  • Complete asynchronous interface using promises.


  • New option --undo to convert a/b structure back to a simple file or directory.


  • New option --copy to copy existing file or directory to inactive selection on initialize.


  • Can convert existing files or directories.
  • New options --file and --directory to select file or directory mode.


  • Initial public version.


Pull requests, patches, emails, issues, what ever, are welcomed!


Built With


This project is licensed under the MIT License - see LICENSE for details.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free