ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

TS_NODE_CACHE environment variable is not working

Open JoseAntonioRodriguez opened this issue 10 years ago • 0 comments

How should I set the TS_NODE_CACHE variable to avoid using the cache? Values such as 0 or false don't work because values retrieved from process.env are always strings, and that prevent the following code from working:

function readThrough (...) {
  if (options.cache === false) {
    return function (code: string, fileName: string) {
      [...]
    }
  }
}

options.cache will be always evaluated as true if it is a string (and it is if it comes from an environment variable).

Other boolean-like options are working because the way they are evaluated, but could be confusing. This code:

if (options.disableWarnings) {
  return []
}

is working because if I set TS_NODE_DISABLE_WARNINGS=1, 1 is truthy. The funny thing is that if I set it to 0 it is still truthly (because it is a string) and it wouldn't work as expected.

JoseAntonioRodriguez avatar Sep 30 '16 10:09 JoseAntonioRodriguez