ubborg-resolve-homedir-tilde-by-user-plan-pmb

Resolve paths that start with `~` to be within some planned user's planned home directory.

Usage no npm install needed!

<script type="module">
  import ubborgResolveHomedirTildeByUserPlanPmb from 'https://cdn.skypack.dev/ubborg-resolve-homedir-tilde-by-user-plan-pmb';
</script>

README



ubborg-resolve-homedir-tilde-by-user-plan-pmb

Resolve paths that start with ~ to be within some planned user's planned home directory.

API

This module exports one function:

resolveHomeDirTildeByUserPlan(spawnCtx, path, defaultUserName)

path is your original path string. If it doesn't start with '~', it's just returned verbatim.

defaultUserName is the username to look up in case there's no username directly following the tilde, i.e. if path is just ~ or starts with ~/.

spawnCtx should be your resource's lineage context, your module's simplified lineage context, or something else that supports .getResourcesByTypeName().

Returns a promise for the resolved (absolute) path.

Usage

There should be code examples in the sources of ubborg-planner-pmb, just search for this module's name in import statements. (At time of writing, specifically src/resTypes/xdgDesktopEntry.mjs.)

Known issues

  • Needs more/better tests and docs.

 

License

ISC