Getting Started

PathRoute

This npm package gives you the ability to easily access and manage the file paths of your project. Our core function is to provide a simple and intuitive way to navigate the folders and files within your project, making it easier to organize and maintain your codebase. Whether you're working on a small project or a large-scale application, this package can save you time and hassle by streamlining your file management workflow. Try it out and see how it can benefit your development process.

Installation

Inside your Node project directory, run the following:

shell yarn add @vorlefan/path

Quick Start

It is recommended that you create a new file at the source folder of your project where your code is located, be it 'src' or whatever.

Example, create a new file named: src/path.ts

import { PathRoute } from '@vorlefan/path';
 
// creates a default pathRoute
const ProjectRoute = new PathRoute();
ProjectRoute.add('root', __dirname);
 
export { ProjectRoute };

Now you can start to interact over your folder and files from the project, example:

// creates a new folder named the version of your package.json and creates a new file named the name from
// package.json and fills with the current Date
 
const packageJson = await ProjectRoute.json().read(
    ProjectRoute.plug('root', 'package.json') || ''
);
if (packageJson) {
    const name = packageJson.name.replace(/@|\//gm, '_');
    await ProjectRoute.inject('packageJsonVersion', 'root', packageJson.version)
        .io()
        .write(
            ProjectRoute.plug('packageJsonVersion', name) || '',
            new Date().toDateString(),
            true
        );
}