-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
576 additions
and
636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
import pkgUp from 'pkg-up' | ||
|
||
import { fileURLToPath } from 'url' | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
const TSCONFIG_JSON_CONTENT = `{ | ||
"extends": "@pocket-tools/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "src", | ||
}, | ||
"exclude": [ | ||
"node_modules/", | ||
"dist/" | ||
], | ||
"include": [ | ||
"src/**/*.ts", | ||
"src/config" | ||
], | ||
} | ||
` | ||
|
||
async function main () { | ||
const cwd = path.join(__dirname, '..', '..') | ||
const pkg = await pkgUp({ cwd }) | ||
if (!pkg) { | ||
return 0 | ||
} | ||
const pkgDir = path.dirname(pkg) | ||
|
||
const tsconfigFile = path.join(pkgDir, 'tsconfig.json') | ||
|
||
if (!fs.existsSync(tsconfigFile)) { | ||
console.info(`@pocket-tools/tsconfig: auto generated ${tsconfigFile}`) | ||
fs.writeFileSync(tsconfigFile, TSCONFIG_JSON_CONTENT) | ||
} | ||
return 0 | ||
} | ||
|
||
main() | ||
.then(process.exit) | ||
.catch(e => { | ||
console.error(e) | ||
process.exit(1) | ||
}) |
Oops, something went wrong.