I am building a typescript/node.js based package that has two directories called folderOne
and folderTwo
. folderOne
has a file called folderOneFile.ts
. When the package is run as a tool installed from yarn, code from folderOne.ts
is run as follows:
import * as shell from 'shelljs';
shell.exec(`cd folderTwo && pwd`);
I hoped that this would output the path to the folderTwo
directory within the package (as you would expect from pwd
), but instead I got an error saying:
/bin/sh: 1: cd: can't cd to folderTwo
I presume this is because the code is working with the user's terminal/shell rather than the the directories/path within the package itself. Is there any change I can make such that I can somehow work with the directories/paths within the package itself, rather than that of the user's own terminal? I know there are variables like __filename
and __dirname
that will allow me to output the directory, but my ultimate aim is to be able to write bash/shell commands that work with the contents of the package itself, so any advice on how to make the shell command work (with using pwd) would be greatly appreciated.