diff --git a/README.md b/README.md index bb290fc..718468f 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,19 @@ yarn add -D vue-script-tsc ``` ### CLI -You can run `vue-script-tsc` as a script. + +You can run `vue-script-tsc` as a script, for example in package.json or on the command line. + +```json +// package.json +"scripts": { + "tsc": "yarn vue-script-tsc --root ." +} +``` ```bash -vue-script-tsc --root . +# Command line +yarn vue-script-tsc --root . ``` ### Programmatic @@ -32,13 +41,16 @@ You can call `vue-script-tsc` within your own script. ```ts const { tsc } = require('vue-script-tsc'); -async function checkFiles() { - await tsc({ - root: __dirname +tsc({ + root: process.cwd() +}) + .then(() => { + console.log('Type Check Complete') + }) + .catch((err) => { + console.error(err) + process.exit(1) }) -} - -checkFiles() ``` ### Arguments @@ -50,7 +62,7 @@ You can specify some arguments with either usage. For CLI arguments prepend with | `root` | Current Directory | The relative path to the directory to be treated as the root (where your `tsconfig.json` file exists) | | `src` | `/src` | The relative path to the src directory containing your vue files | | `tsconfig` | `tsconfig.json` | The name of your `tsconfig.json` file | -| `tsbuildinfo` | Settings in `tsconfig.json` | If using `incremental` builds, the relative path to where to store the `.tsbuildinfo` file | +| `tsbuildinfo` | Setting in `tsconfig.json` | If using `incremental` builds, the relative path to where to store the `.tsbuildinfo` file | ## Comparisons diff --git a/src/args.ts b/src/args.ts index e71f00c..5726297 100644 --- a/src/args.ts +++ b/src/args.ts @@ -20,9 +20,9 @@ export interface Options { } export function parseArgs(opts: Options): Required { - const cwd = resolve(__dirname) + const cwd = process.cwd() const root = opts.root ? resolve(cwd, opts.root) : cwd - const src = opts.src ? resolve(cwd, opts.src) : resolve(cwd, 'src') + const src = opts.src ? resolve(cwd, opts.src) : resolve(root, 'src') const tsconfig = opts.tsconfig || 'tsconfig.json' const tsbuildinfo = opts.tsbuildinfo ? resolve(cwd, opts.tsbuildinfo) : '' diff --git a/src/cli.ts b/src/cli.ts index 93e0bea..b4b41eb 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -7,3 +7,10 @@ import { Options } from './args' const options = minimist(process.argv.slice(2)) as Options tsc(options) + .then(() => { + console.log('Type Check Complete') + }) + .catch((err) => { + console.error(err.message) + process.exit(1) + })