JSPM

thot-cwd

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q39376F
  • License MIT

Fixes potential issue with cwd when running script from a different location

Package Exports

  • thot-cwd

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 (thot-cwd) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

thotjs-cwd

Fixes potential issue with cwd when running a script from outside of it's base path

This module is only meant to be used on the entry point of your application. Please do not use it on internal modules. As changing the current working directory after instantiation can cause required filepaths to break.

Usage

npm install --save thotjs-cwd
var cwd = require('thotjs-cwd');

If you'd like you can store a reference to the current working directory for use in a relative require to the application root. This isn't necessarily recommended but I've found instances where I don't want to type ../../../ a few times over mainly because I'm lazy.

If you do use it for this purpose please use path.resolve to handle the paths so you don't run into issues with differing OS directory separators. I would recommend thot-local-require if this is your intended use case. See told you I was lazy :).

NOTE:

I built this for personal projects to ensure that the paths to files were correct. It's not the only solution to the problem but it works and works well as long as you remember that you forced the directory