How to get the current directory within a meteor Smart Package

北慕城南 提交于 2019-12-06 04:04:43

If you don't want the content, but an absolute path for another tool, you can try

var path = Npm.require('path');
var base = path.resolve('.');
var assetsBase = path.join(base, '/assets/packages/<author_smart-package-name>');

For the <author_smart-package-name> enter your package name, but if it has your meteor user name included, change the colon (:) to underscore (_)

That seems okay on OS X and Linux, probably works in windows as well.

Mitar

Why would you need current directory? To access a file inside the package? Then add a file as n package asset:

api.add_files(['file.txt'], 'server', {isAsset: true});

And then you can read it with Assets.getText('file.txt') in your package.

oops, this is for files within the app, not a package. anyway maybe helpful to someone

I need to access a directory path for loading a list of files

// files in /private get built to:
//      .meteorlocal/build/programs/server/assets/app/
// base path resolves to:
//      .meteor/local/build/programs/server

so you need to manually add "/assets/app" to your paths.

until meteor change this at some point.

just getting to the content of a file isn't helpful if you have a directory of changing content...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!