ProjectRoot.jl

Easy file-referencing for project-oriented workflows
Author jolars
Popularity
5 Stars
Updated Last
7 Months Ago
Started In
January 2024

ProjectRoot

Build Status

A package for Julia that provides easy file-referencing for project-oriented workflows.

Installation

You can install the package using the Julia package manager:

]add ProjectRoot

Alternatively, you can also install the latest development version of the package from the source code on GitHub by calling

using Pkg
Pkg.add(url = "https://github.com/jolars/ProjectRoot.jl")

Getting Started

The package provides a single macro, @projectroot, that can be used to reference files in your project. The idea is to in some file A.jl be able to reference another file B.jl somewhere else in your project without having to care where file A.jl is or need to update the reference if you move A.jl somewhere else.

Take this example project:

MyProject
├── scripts
│   └── A.jl
├── src
│   └── B.jl
└── Project.toml

If you want to include B.jl from A.jl, all you need to do is this:

include(@projectroot("src", "B.jl"))

Now, calling A.jl from anywhere in your project will work as expected. And if you move A.jl to another folder, say scripts/subfolder, the import will still work.

@projectroot also handles calling lines from A.jl through the REPL, by fetching the current working directory.

Contributing

When writing commit messages, please use the conventional commits format.

Versioning

ProjectRoot uses semantic versioning.

Required Packages

Used By Packages

No packages found.