https://deno.land/x/easypath 

Deno easyPath Build Status

Path wrapper to manipulate Filesystem using Deno. Mostly inspired by Path.swift

Concept

easyPath give you the possibility to manipulate the FileSystem of Deno using chains of actions. After the declaration you can execute all the actions synchronously or asynchronously. Also you can have nested chains, see copy example.

API

Actions

Copy

Copy will copy the current path to or into the passed option. to or into can either be a path string or an easyPath instance. Also this instance has not to have its chain executed, it will be executed with the main easyPath instance. See example below:

path()
  .join("foo.ts")
  .copy({
    into: path()
      .join("sub")
      .mkdir()
  })
  .execSync();
export interface CopyOption {
  to?: EasyPath | string;
  into?: EasyPath | string;
}
path()
  .join("foo.ts")
  .copy({
    into: path().join("sub")
  });
// Will copy ./foo.ts to ./sub/foo.ts
path()
  .join("foo.ts")
  .copy({
    into: path()
      .join("sub")
      .join("bar.ts")
  });
// Will copy ./foo.ts to ./sub/bar.ts

Status

Those statuses only work on a path without action in the chain. If so, you have to exec the chain before getting the status.

Dynamic getters

easyPath uses Javascript Proxy to have possibility to write syntax like this:

path('~').foo.bar.bur.bor.toString();
// output ~\foo\bar\bur\bor

Examples

import { path } from "https://deno.land/x/easypath/mod.ts";

path("/")
  .join("foo")
  .join("bar.ts")
  .toString(); // output /foo/bar.ts

path()
  .join("bar.ts")
  .touch()
  .execSync(); // create ./bar.ts Synchronously

const e = path()
  .join("bar.ts")
  .touch();
await e.exec(); // create ./bar.ts Asynchronously

// you can also chain actions
path()
  .join("subFolder")
  .mkdir()
  .join("foo.ts")
  .touch()
  .execSync(); // create ./subFolder/bar.ts Synchronously

const e = path()
  .join("subFolder")
  .mkdir()
  .join("foo.ts")
  .touch();
await e.exec(); // create ./subFolder/bar.ts Asynchronously

path()
  .join("foo.ts")
  .copy({ to: path(testRootPath).join("bar.ts") })
  .execSync();
// Will copy ./foo.ts to ./bar.ts

path()
  .join("foo.ts")
  .copy({ into: path(testRootPath).join("sub") })
  .execSync();
// Will copy ./foo.ts to ./sub/bar.ts

// copy accept also EasyPath chains.
path(testRootPath)
  .join("foo.ts")
  .copy({
    into: path(testRootPath)
      .join("sub")
      .mkdir()
  })
  .execSync();
// Will copy ./foo.ts to ./sub/bar.ts
// Note chains in the copy args are executed synchronously

TODO