JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q40390F

Package Exports

  • @brillout/get-user-dir

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@brillout/get-user-dir) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

For libraries to get the directory of the user's code.

More precisely, getUserDir returns the first directory in the call stack trace that is not in node_modules/.

Usage Example

const getUserDir = require('@brillout/get-user-dir');

const userDir = getUserDir();

You can as well manually set the "user directory":

const getUserDir = require('@brillout/get-user-dir');

const userDir = '/path/to/user/code'
getUserDir.userDir = userDir;

assert(getUserDir() === userDir);

This is typically used in the context of a CLI. The CLI entry module then does getUserDir.userDir = process.cwd();. (The user-code directory can't be retrieved with a call stack coming from a CLI call. Instead, process.cwd() can act as user-code directory.)