path-insert

1.0.0 • Public • Published

path-insert

Insert a path into another path

Travis npm

Installation

npm install path-insert

Usage

const pathInsert = require('path-insert');

const path = '/Users/geoff/Videos/secret-videos/puppers/doggo.mov';

pathInsert.start(path, '/Users/geoff/Videos', 'real-secret-videos');
// => '/Users/geoff/Videos/real-secret-videos/secret-videos/puppers/doggo.mov'

pathInsert.end(path, 'secret-videos/puppers/doggo.mov', 'real-secret-videos');
// => '/Users/geoff/Videos/real-secret-videos/secret-videos/puppers/doggo.mov'

API

pathInsert.start(path, base, insert)

Insert a string in the middle of a path, using a segment at the base of the path as the target.

  • path (String): Full path.
  • base (String): Path segment to insert replacement after.
  • insert (String): Path segment to insert.

Returns a modified path with insert inserted into string.

pathInsert.end(path, end, insert)

Insert a string in the middle of a path, using a segment at the end of the path as the target.

  • path (String): Full path.
  • end (String): Path segment to insert replacement before.
  • insert (String): Path segment to insert.

Returns a modified path with insert inserted into string.

Local Development

git clone https://github.com/gakimball/path-insert
cd path-insert
npm install
npm test

License

MIT © Geoff Kimball

Readme

Keywords

Package Sidebar

Install

npm i path-insert

Weekly Downloads

4

Version

1.0.0

License

MIT

Last publish

Collaborators

  • gakimball