ts-purify
v3.0.5
Published
ensure compiled typescript files are removed when the corresponding source files are
Downloads
175
Readme
ts-purify
Motivation
When compiling typescript files in src
to an output directory in dist
with tsc
, the js
files already existing in dist
are left alone, potentially interfering with the build system and tests.
ts-purify
deletes all js
and js.map
files in the output directory with no corresponding ts
files when it is run. It can also be configured to watch the source directory for deletions and then delete corresponding output files as they occur.
Instructions
To recursively delete all js
and js.map
files in dist
with no corresponding ts
file in src
:
% ts-purify -s src -d dist
To do the same as the above command, then use watchman
to scan src
for deleted ts
files and remove files from dist
as necessary:
% ts-purify -s src -d dist -w
These invocations show the defaults for -s
and -l
, they can be omitted when also using src
and dist
respectively.
The -v
or --verbose
option can be used to log deleted files. The -p
option can be used to use watchman's watch-project
command instead of watch
.
In most cases package.json
scripts
will just need to be modified from something like:
{
"build:watch": "tsc -p . -w"
}
To:
{
"build:watch": "ts-purify -w & tsc -p . -w"
}
To support Windows, use concurrently
instead of &
:
{
"build:watch": "concurrently \"ts-purify -w\" \"tsc -p . -w\""
}