run-ts
A tools to use Typescript files as npm scripts
Gist
before
after
How to
run-ts
1. Install npm install --save-dev run-ts# or yarn add --dev run-ts
scripts
folder
2. Create a mkdir scripts
scripts/tsconfig.json
file
3. Create a
scripts/my-script.ts
file
4. Create a ;console.logfoo;
my-script
scripts in your package.json
5. Create a
That's it, now when you run npm run my-script
the scripts/my-script.ts
file is executed.
Using args
If your file export a function as default
, run-ts
will execute this function with the arguments as first parameter:
// scripts/setup.ts
Note: You can also use process.argv
but you have to strip the first two items (node
and run-ts
)