2014-12-30 3 views
0

나는 유성 1.0.2.1을 사용하고 있는데 나는 파일 시스템과 함께 작업하는 내가 문질러서처럼 쉬운 일이 아닙니다 것으로 나타났습니다 : Pmeteor : 프로젝트 루트 경로에서 파일 및 디렉토리를 나열하는 방법은 무엇입니까?

나는 peerlibrary 설치, 종료 : 지금에 액세스 할 수 있도록 FS 패키지 (https://atmospherejs.com/peerlibrary/fs를) Node.js를 "FS"모듈은 지금은 공용 폴더의 내용을 표시하기 위해 노력하고있어하지만 같이 여기에 언급 : (버전 1)

지금

Reading files from a directory inside a meteor app

경로 '가 될 것으로 보인다 .. /../../../../public '

var files = fs.readdirSync('../../../../../public');

그러나 나는 이것이 틀렸다고 가정합니다.

프로젝트 루트 폴더에 별칭이 있습니까? peerlibrary : fs를 사용해도 되니?

감사합니다.

+0

당신은 process.env.PWD, fs.readdirSync (process.env.PWD + '/ public')를 사용할 수 있습니다; –

+0

안녕하세요 @Alexander, 답장을 보내 주셔서 감사합니다. 내가 옳다면 유일한 단점은 환경 변수에 의존한다는 것입니다. 다른 결과를 얻을 수 있습니다. 예를 들어,/my/project/server에서 "meteor run"을 실행하면/my/project 대신 후자가됩니다. – Giovanni

답변

0

_meteor_bootstrap_의 CONSOLE.LOG (나는 개인 콘텐츠를 제거)

{ startupHooks: 
    [ [Function],  [Function], 
     [Function],  [Function], 
     [Function], 
     [Function], 
     [Function], 
     [Function], 
     [Function] ], 
    serverDir: 'my_path_to_serverDir', 
    configJson: 
    { meteorRelease: '[email protected]', 
     clientPaths: { 'web.browser': '../web.browser/program.json' } } } 
=> Started your app. 

내가 /home/user/app/.meteor/local/build/programs/web.browser/에서 program.json을 확인 않았다고 그건 내가 상태가에

{ 
    "path": "app/pathToImage/image.png", 
    "where": "client", 
    "type": "asset", 
    "cacheable": false, 
    "url": "/pathToimage/image.png", 
    "size": someSize, 
    "hash": "someHash" 
}, 

이 배치 된 상태에서 공용 폴더는 없지만 당신이 program.json 파일에서 경로를 얻을 수 _meteor_bootstrap_.configJson.clientPaths 객체를 제공합니다 (I 몇 가지 개인 정보를 변경)처럼의 program.json 일부가 보인다 그것으로 보이는 경로는 이것처럼 보입니다 (console.log에서 붙여 넣기) :
{ 'web.browser': '../web.browser/program.json' }

+1

/my/project/.meteor/local/build/programs를 반환하는'__meteor_bootstrap __. serverDir'가 있습니다./server 그러므로 ".meteor"문자열을 사용하여 그 전에 모든 것을 취할 수는 있지만 이것이 얼마나 견고 할 지 확신 할 수 없습니다. – Giovanni

관련 문제