From 6a3cc05c94682eccdca431fbc57873d26f7e6f44 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 4 Sep 2024 10:46:51 +1000 Subject: [PATCH] feat: add path handling requirement Paths can be a source of confusion/annoyances especially when sharing across operating systems. Therefore, explicit requirements are set. Signed-off-by: JP-Ellis --- rfc/0000-configuration-and-shared-files.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rfc/0000-configuration-and-shared-files.md b/rfc/0000-configuration-and-shared-files.md index b86a8ce..e0e79da 100644 --- a/rfc/0000-configuration-and-shared-files.md +++ b/rfc/0000-configuration-and-shared-files.md @@ -222,6 +222,21 @@ The following tables are proposed: enable_other_feature = false ``` +#### Path Handling + +To ensure a uniform experience across the Pact ecosystem and operating systems, the following rules _must_ be followed when handling paths in the configuration file: + +- Paths _must_ be stored using the forward slash (`/`) as the path separator. + - This avoids the need to escape backslashes (`\`) in Windows paths. + - If a backslash is used, it is undefined behaviour. The implementation _may_ attempt to convert the backslashes to forward slashes, but this is not required. +- The tilde (`~`) character _must_ be expanded to the user's home directory if it is the first character in a path. + - For example, parsing `~/.local/share/pact` should result in `/home/user/.local/share/pact` on Unix-like systems. + - If the tilde appears elsewhere in the path, it is treated as a literal character. + - If someone wishes to use a literal tilde for a relative path, they _must_ use `./~` instead. +- Relative paths are allowed, and _must_ be resolved relative to the configuration file. + - For example, if the configuration file is located at `/workdir/project/.pact.toml`, and a value is set to `.pact/data`, the resolved path should be `/workdir/project/.pact/data`. + + ### Shared Files At present, there are only a few files which are shared across the Pact ecosystem. These are: