• Stars
    star
    7
  • Rank 2,294,772 (Top 46 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 2 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ƒ Typed primitives for Typescript to work with file paths

typed-file-system-path

typed-file-system-path

typed-file-system-path takes inspiration from Path.swift in swift-tools-support-core and provides typed primitives to work with file-system paths instead of strings. Even though it might seem unnecessary because it wraps a the string representing the path, it allows designing APIs that make it explicit if they work with absolute or relative paths and logic that doesn't have to make any assumptions.

We strongly recommend turning relative paths into absolute ones as soon as they enter the system. For example, if a path is passed through a flag in a CLI, make it absolute before you pass it down.

Usage

import { relativePath, absolutePath } from "typed-file-system-path"

// Initialize an absolute path
// @throws InvalidAbsolutePathError if the path is not absolute.
const dirAbsolutePath = absolutePath("/path/to/dir")

// Initialize a relative path
// @throws InvalidRelativePathError if the path is not relative.
const fileRelativePath = relativePath("./tsconfig.json")

/** Functions common across absolute and relative paths **/
path.parentDirectory // The parent directory path
path.extension // The path extension or undefined otherwise
path.basename // The path's last component
path.basenameWithoutExtension // The path's last component without the extension

path.appending("src", "index.ts") // Returns a new path appending a relative path
path.appending("src/index.ts")
path.appending(relativePath("src/index.ts"))

Setup for development

  1. Clone the repo: git clone https://github.com/pepicrft/typed-file-system-path.
  2. Install dependencies: pnpm install.
  3. Build the project: pnpm build.
  4. Test the project: pnpm test.

More Repositories

1

PPiAwesomeButton

UIButton category with new methods to setup a button with text + FontAwesome Icon
Objective-C
496
star
2

catalysis-framework

A full-stack Javascript framework ยท Built for the long-term
TypeScript
51
star
3

xcode-modular-apps-workshop

Mobos Conference (Romania) about building modular apps with Xcode
Swift
23
star
4

developing-modular-apps-on-ios

Slides from the talk that I gave at NSCoder Night Madrid
7
star
5

node-module-benchmarker

๐Ÿš€ A CLI to benchmark the loading of an ESM graph in Node
TypeScript
3
star
6

pepicrft.me

๐Ÿฃ Personal website powered by Phoenix (pepicrft.me)
Elixir
3
star
7

dotfiles.nix

Dotfiles powered by Nix and home-manager
Nix
2
star
8

gestalt

๐ŸŽจ A Rust-powered and language-agnostic solution to build interactive UIs for web apps
2
star
9

intrepid-adventure-of-scaling-mobile-apps-talk

The slides of my presentation "The intrepid adventure of scaling a mobile apps"
2
star
10

modulex

๐Ÿ“ฆ Generate a module whose implementation can be swapped at runtime with tools like Mox
Elixir
1
star
11

detect-create-package-manager

An NPM package to detect the package manager used for running the "create" command
TypeScript
1
star
12

still_scss

๐ŸŽจ A scss preprocessor for the Still static site generator
Elixir
1
star
13

noora

๐ŸŒฑ Noora is a native UI compiler for the web
1
star
14

encrypted-environment

Ruby utility to load encrypted variables into the environment
Ruby
1
star
15

WDM_over_POF

Analysis and viability of WDM technology in POF networks - Final degree project
TeX
1
star
16

rssletter

โœ‰๏ธ Turn newsletter subscriptions into a RSS feed
Elixir
1
star
17

website-old

๐ŸŒ Pedro Piรฑera's personal static website
HTML
1
star
18

pepicrft.me-next

๐Ÿ‘ฉโ€๐Ÿš€ Personal website implemented with NextJS
JavaScript
1
star
19

gestaltjs

A full-stack and batteries-included NodeJS framework designed and built for the long-term
1
star
20

Tratamiento-Digital-de-Im-genes-iOS

Asignatura de tratamiento de digital de imรกgenes trasladada a iOS con todos los ejercicios de la asignatura.
Objective-C
1
star
21

simple-dynamic-configuration-tuist

A repository that showcases how to use dynamic configuration in Tuist
Swift
1
star
22

bodamariajoseypedro

JavaScript
1
star
23

solare

Solare is an iOS application to alert user how dangerous UV is
Objective-C
1
star
24

pepicrft

1
star