It appears the cwd option isn’t always honored, specifically when I run the following script from the symlinked directory of the specified cwd, but running from all other directories works fine. What is the explanation for this behavior?

➜  ~ pwd
/Users/foo
➜  ~ cat temp/script.tsx
  const { exec } = require('child_process');

  const p = exec(
      'pwd',
      {
          cwd: '/Users/foo/temp'
      },
      (_, stdout) => {
          console.log(`stdout: ${stdout}`);
      }
  );
➜  ~ ts-node temp/script.tsx
stdout: /Users/foo/temp

➜  ~ ln -s temp temp-symlink
➜  ~ ts-node temp-symlink/script.tsx
stdout: /Users/foo/temp

➜  ~ cd temp-symlink && ts-node script.tsx
stdout: /Users/foo/temp-symlink  // <--- how?
0

There are 0 answers