I'm currently using a javascript function from my package.json script, but I want to switch it to a typescript function in a typescript file. Can someone advise me on how to make this adjustment?
This is the javascript code that runs the desired function:
"scripts": {
"command": "node -e 'require(\"./javaScriptFileName\").functionName()'"
}
Here is the typescript file exporting the function:
const fs = require("fs");
module.exports.functionName = function(path: string): void
{
if(fs.exists(path))
{
console.log("Exists");
}
}
I've tried using the ts-node package and replacing "node" with "ts-node", but it didn't work as expected.