Skip to content

Commit

Permalink
fix: tsc 没有正确退出
Browse files Browse the repository at this point in the history
  • Loading branch information
cjg1122 committed Sep 29, 2024
1 parent 909117e commit 1d165f2
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.DS_Store
.DS_Store
dist
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## 使用

### 1. lint-staged

.lintstagedrc.json

```json
{
"*.{ts,tsx}": "npx --no-install tscf --include src/**/*.d.ts --files"
}
```

### 2. lefthook

lefthook.yaml

```yaml
pre-commit:
parallel: true
commands:
tsc:
glob: "*.{ts,tsx}"
run: npx --no-install tscf {staged_files} --include src/**/*.d.ts
```
## 安装
```sh
Expand Down
1 change: 0 additions & 1 deletion dist/bin.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dist/bin.js

This file was deleted.

8 changes: 0 additions & 8 deletions dist/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.js

This file was deleted.

31 changes: 27 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-check-files",
"version": "1.0.0",
"version": "1.0.1",
"description": "typesctipt check files",
"type": "module",
"main": "dist/index.js",
Expand All @@ -10,16 +10,39 @@
},
"scripts": {
"dev": "tsup --watch",
"build": "tsup"
"build": "tsup",
"prepublishOnly": "npm run build"
},
"files": ["dist"],
"keywords": [],
"author": "",
"keywords": [
"typescript",
"check",
"tsc",
"tscf",
"ts-check-files",
"tscheckfiles",
"tsc-files"
],
"repository": {
"type": "git",
"url": "https://github.com/cjg1122/ts-check-files"
},
"author": {
"name": "cjg",
"url": "https://github.com/cjg1122"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/cjg1122/ts-check-files/issues"
},
"devDependencies": {
"@biomejs/biome": "1.9.2",
"@types/node": "^22.7.4",
"tsup": "^8.3.0",
"typescript": "^5.6.2"
},
"engines": {
"node": ">=18.0.0",
"pnpm": ">=9.0.0"
}
}
14 changes: 11 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,19 @@ function tscf(args: {
"utf8",
);

spawnSync("npx", ["tsc", "-p", tsTmpConfigPath], {
stdio: "inherit",
});
const result = spawnSync(
"npx",
["--no-install", "tsc", "-p", tsTmpConfigPath],
{
stdio: "inherit",
},
);

fs.unlinkSync(tsTmpConfigPath);

if (result.status !== 0) {
process.exit(result.status);
}
}

export default tscf;

0 comments on commit 1d165f2

Please sign in to comment.