Skip to content

Commit 439f133

Browse files
committed
add --restart flag, remove incorrect documentation section
1 parent c3bcd8f commit 439f133

File tree

5 files changed

+86
-43
lines changed

5 files changed

+86
-43
lines changed

README.md

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -226,33 +226,6 @@ when there are compilation diagnostics.
226226
diagnostics. (Similar to ts-node's `TS_NODE_TRANSPILE_ONLY=1`
227227
option.)
228228

229-
You can also set `diagnostics` as a top-level field in the
230-
`tsimp` object in `tsconfig.json`. For example:
231-
232-
```json
233-
{
234-
"compilerOptions": {
235-
"rootDir": "./src",
236-
"declaration": true,
237-
"esModuleInterop": true,
238-
"forceConsistentCasingInFileNames": true,
239-
"inlineSources": true,
240-
"jsx": "react",
241-
"module": "nodenext",
242-
"moduleResolution": "nodenext",
243-
"noUncheckedIndexedAccess": true,
244-
"resolveJsonModule": true,
245-
"skipLibCheck": false,
246-
"sourceMap": false,
247-
"strict": true,
248-
"target": "es2022"
249-
}
250-
"tsimp": {
251-
"diagnostics": "error"
252-
}
253-
}
254-
```
255-
256229
## How fast is it?
257230

258231
If the daemon is running, it's very fast, even if type checking
@@ -314,6 +287,6 @@ sys 0m0.022s
314287

315288
## How is it so fast?
316289

317-
![meme comic "We need this to run faster" "rewrite it in rust" "rewrite it in zig" "use basic caching and work skipping" guy gets thrown out window](./faster.jpg)
290+
![meme comic "We need this to run faster" "rewrite it in rust" "rewrite it in zig" "use basic caching and work skipping" guy gets thrown out window](https://github.com/tapjs/tsimp/raw/main/faster.jpg)
318291

319292
Basic caching and work skipping.

package-lock.json

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"typescript": "^5.1.0"
6868
},
6969
"devDependencies": {
70+
"@swc-node/register": "^1.6.8",
7071
"@types/node": "^20.8.4",
7172
"chalk": "^5.3.0",
7273
"prettier": "^2.8.8",

src/bin.mts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,33 @@ const usage = () =>
3535
3636
Flags:
3737
38-
--start Start the persistent daemon and preload the TypeScript
39-
program object for typecheck compilation.
40-
--stop Kill the persistent daemon process.
41-
--clear Kill daemon and clear all cached data and logs.
42-
--ping Issue a PING request to daemon and print result.
43-
--help You're looking at it.
44-
--log Display the daemon log (ie, \`cat .tsimp/daemon/log\`)
38+
--start Start the persistent daemon and preload the TypeScript
39+
program object for typecheck compilation.
40+
--stop Kill the persistent daemon process.
41+
--restart Stop and then start again.
42+
--clear Kill daemon and clear all cached data and logs.
43+
--ping Issue a PING request to daemon and print result. Will start
44+
the daemon if not already running.
45+
--help You're looking at it.
46+
--log Display the service log (ie, \`cat .tsimp/daemon/log\`)
4547
4648
--compile <fileName>
47-
Compile the specified TypeScript fileName, printing code
48-
to stdout and diagnostics to stderr.
49+
Compile the specified TypeScript fileName, printing code
50+
to stdout and diagnostics to stderr.
51+
52+
--check <fileName>
53+
Same as --compile, but do not output the code.
4954
5055
--resolve <module> [<parent>]
51-
Resolve the specified module name (ie, find the .ts file for
52-
a .js import specifier). Will print either a full file://
53-
url to the found module, or echo the specifier back.
56+
Resolve the specified module name (ie, find the .ts file for
57+
a .js import specifier). Will print either a full file://
58+
url to the found module, or echo the specifier back.
5459
5560
Flags have no effect unless they are the first argument.
5661
57-
If none of the above flags are specified, then tsimp runs node using the
58-
appropriate '--loader=tsimp/loader' or '--import=tsimp/import' for the
59-
current node version.
62+
If none of the above flags are specified, then tsimp runs node using
63+
'--loader=tsimp/loader' or '--import=tsimp/import', as appropriate for
64+
the current node version.
6065
6166
All other args are just normal node arguments.
6267
@@ -135,6 +140,10 @@ switch (process.argv[2]) {
135140
case '--clear':
136141
await clearCache()
137142
process.exit(0)
143+
case '--restart':
144+
await stopDaemon()
145+
await startDaemon()
146+
process.exit(0)
138147
case '--start':
139148
await startDaemon()
140149
process.exit(0)

test/bin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ t.test('start', async t => {
3232
t.equal(statSync('.tsimp/daemon/pid').isFile(), true)
3333
})
3434

35+
t.test('restart', async t => {
36+
run(['--restart'])
37+
t.equal(statSync('.tsimp/daemon/pid').isFile(), true)
38+
})
39+
3540
t.test('clear', async t => {
3641
run(['--clear'])
3742
t.throws(() => statSync('.tsimp'))

0 commit comments

Comments
 (0)