Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename env vars to use TSX prefix #372

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ To set a custom path, use the `--tsconfig` flag:
tsx --tsconfig ./path/to/tsconfig.custom.json ./file.ts
```

Alternatively, use the `ESBK_TSCONFIG_PATH` environment variable:
Alternatively, use the `TSX_TSCONFIG_PATH` environment variable:

```sh
ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json tsx ./file.ts
TSX_TSCONFIG_PATH=./path/to/tsconfig.custom.json tsx ./file.ts
```

### Watch mode
Expand Down Expand Up @@ -147,6 +147,12 @@ Set the `--no-cache` flag to disable the cache:
tsx --no-cache ./file.ts
```

Alternatively, use the `TSX_DISABLE_CACHE` environment variable:

```sh
TSX_DISABLE_CACHE=1 tsx ./file.ts
```

### Node.js Loader

`tsx` is a standalone binary designed to be used in place of `node`, but sometimes you'll want to use `node` directly. For example, when adding TypeScript & ESM support to npm-installed binaries.
Expand Down
6 changes: 3 additions & 3 deletions src/cjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const isTsFilePatten = /\.[cm]?tsx?$/;
const nodeModulesPath = `${path.sep}node_modules${path.sep}`;

const tsconfig = (
process.env.ESBK_TSCONFIG_PATH
process.env.TSX_TSCONFIG_PATH
? {
path: path.resolve(process.env.ESBK_TSCONFIG_PATH),
config: parseTsconfig(process.env.ESBK_TSCONFIG_PATH),
path: path.resolve(process.env.TSX_TSCONFIG_PATH),
config: parseTsconfig(process.env.TSX_TSCONFIG_PATH),
}
: getTsconfig()
);
Expand Down
6 changes: 3 additions & 3 deletions src/esm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { getPackageType } from './package-json.js';
export const applySourceMap = installSourceMapSupport();

const tsconfig = (
process.env.ESBK_TSCONFIG_PATH
process.env.TSX_TSCONFIG_PATH
? {
path: path.resolve(process.env.ESBK_TSCONFIG_PATH),
config: parseTsconfig(process.env.ESBK_TSCONFIG_PATH),
path: path.resolve(process.env.TSX_TSCONFIG_PATH),
config: parseTsconfig(process.env.TSX_TSCONFIG_PATH),
}
: getTsconfig()
);
Expand Down
4 changes: 2 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export function run(

if (options) {
if (options.noCache) {
environment.ESBK_DISABLE_CACHE = '1';
environment.TSX_DISABLE_CACHE = '1';
}

if (options.tsconfigPath) {
environment.ESBK_TSCONFIG_PATH = options.tsconfigPath;
environment.TSX_TSCONFIG_PATH = options.tsconfigPath;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/transform/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class FileCache<ReturnType> extends Map<string, ReturnType> {
}

export default (
process.env.ESBK_DISABLE_CACHE
process.env.TSX_DISABLE_CACHE
? new Map<string, Transformed>()
: new FileCache<Transformed>()
);
4 changes: 2 additions & 2 deletions tests/utils/tsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const tsx = (
options.args,
{
env: {
ESBK_DISABLE_CACHE: '1',
TSX_DISABLE_CACHE: '1',
DEBUG: '1',
},
nodePath: options.nodePath,
Expand Down Expand Up @@ -51,7 +51,7 @@ export const createNode = async (
{
cwd,
env: {
ESBK_DISABLE_CACHE: '1',
TSX_DISABLE_CACHE: '1',
DEBUG: '1',
},
nodePath: node.path,
Expand Down