This directory is a Yarn workspace that contains
zx
scripts relevant to the repository.
Scripts can be run from within this directory, or, ideally, from within the root
of the repository. See ../CONTRIBUTING.md
for more
details, but tl;dr :
From the root:
yarn zx scripts/print-cwd.ts
From this directory:
yarn zx print-cwd.ts
When running scripts, process.cwd()
will be the directory of the user calling
the script. This is because the yarn zx
alias in the root repository is
not implemented with yarn workspace run
(which would change the working
directory to that of the workspace).
For example, try running yarn zx scripts/print-cwd.ts
(from root), or
yarn zx print-cwd.ts
(from within scripts
):
# From root of repository
❯ yarn zx scripts/print-cwd.ts
[CWD] /path/to/repo/madatdata
# Move to scripts directory and run again
❯ cd scripts/
❯ yarn zx print-cwd.ts
[CWD] /Users/mjr/exp/madatdata/scripts
For writing scripts, see the zx
readme. Note
that certain modules you might normally import from Node are exported from zx
,
like chalk
, fs
, os
, and fetch
.