From: Jacob Rothstein <jacob.rothst...@gmail.com>
Date: Sun, 27 Feb 2011 15:38:26 -0800
Local: Sun, Feb 27 2011 6:38 pm
Subject: Re: [nodejs] Re: Current directory is a symlink?
Hi Kevin,
If I understand your use case, couldn't you just check if the realpath if ( fs.realpathSync ( __dirname + '/../live' ) !== –Jacob On Sun, Feb 27, 2011 at 3:10 PM, Kevin <kbow...@gmail.com> wrote:
> Hi Isaac, > Wow, that's quite a comprehensive answer, many thanks :) > The problem I'm struggling with is this: > """ > I'm not too worried about env-var hijacking, so $PWD is ok for my > Thanks again for your help, I think there just isn't really a good way > Kevin > On Feb 27, 8:49 pm, Isaac Schlueter <i...@izs.me> wrote: >> --i >> On Sun, Feb 27, 2011 at 12:48, Isaac Schlueter <i...@izs.me> wrote: >> > PWD=pwned node -e 'process.env.PWD' // does this output the >> > Even in shell scripts, "$PWD" is not as good as "$(pwd)" for this >> > If you want the real path when running in a directory path that >> > var fs = require('fs') >> > If you want to know the dir that a script lives in, check the >> > var scriptLivesInThisDir = __dirname >> > To get the real path of the cwd, you could do: >> > fs.realpath(process.cwd(), function (er, real) { ... }) >> > There is no way in your script to detect if it was loaded via a >> > To find a file that exists in the same folder as your script, you can >> > var tsFile = path.resolve(__dirname, '.timestamp') >> > To find it in the cwd, you can do: >> > var ts = path.resolve(process.cwd(), '.timestamp') >> > To find it in the real path of the cwd, you can do: >> > var ts = path.resolve(fs.realpathSync(process.cwd()), '.timestamp') >> > Does that answer your question(s)? >> > --i > -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||