Skip to content

veliovgroup/Meteor-root

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

support support

Meteor.rootPath

Get the path to currently running instance of Meteor application on a server.

Features:

  • 🤓 Compatibility with Windows, Linux, and MacOS environments;
  • 👨‍💻 Globally available Meteor.rootPath — absolute path to programs/server directory;
  • 👨‍💻 Globally available Meteor.absolutePath — application root (path before .meteor in rootPath).

meteor-root atmosphere library

Installation

meteor add ostrio:meteor-root

Usage

import path from 'path';

const pathToFile = path.join(Meteor.rootPath, 'directory', 'file.json');

Returns absolute path to programs/server directory of the running app, without trailing slash. Same as server process.cwd().

import path from 'path';

const pathToFile = path.join(Meteor.absolutePath, 'private', 'file.json');

Returns application root when .meteor is present in rootPath (dev, meteor test-packages). In typical production bundles, equals Meteor.rootPath. See docs/paths-and-environments.md.

Note

Paths reflect where Meteor is running, not necessarily your git checkout. Test runners use temporary build directories.

TypeScript

Types ship via meteor-root.d.ts (module augmentation on meteor/meteor). The package uses zodern:types and package-types.json at publish time.

In your app, add zodern:types, configure tsconfig.json paths for meteor/* (see Meteor core types docs), then run meteor lint.

Testing

From the package directory:

npm install
npm test

Runs runtime tests (mtest) and TypeScript declaration tests (tsd). mtest requires a Chromium/Chrome binary for Puppeteer.

npm run test:once     # runtime only
npm run test:types    # declarations only

# Custom port (runtime)
npm run test:once -- --port 8888

# With local MongoDB (runtime)
MONGO_URL="mongodb://127.0.0.1:27017/meteor-root-test" npm run test:once

Special thanks

  • Thanks to @Konard for testing and maintaining Windows support.

Support this project:

About

[Server] ☄️ Get path on a server where Meteor application is currently running

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors