Skip to content

Commit 4b5490a

Browse files
committed
Improve README and add help command
1 parent 569365c commit 4b5490a

File tree

6 files changed

+388
-494
lines changed

6 files changed

+388
-494
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ centralized place rather than repeating the same process for each codebase.
66

77
Inspired by `react-scripts` and `kcd-scripts`.
88

9+
## Table of Contents
10+
11+
- [Installation](#installation)
12+
- [Usage](#usage)
13+
914
## Installation
1015

1116
`npm install @cdimitroulas/typescript-scripts`
1217

1318
## Usage
1419

1520
The `typescript-scripts` script will be available in `node_modules/.bin/typescript-scripts` so
16-
you can either reference it directly by using that path, use `npx typescript-scripts` or if you
17-
are using it within `package.json` simply write `typescript-scripts [script name]`.
21+
you can either reference it directly by using that path or use `npx typescript-scripts`. If you
22+
are using it from a `package.json` script, you can simply write `typescript-scripts [script name]`.
1823

19-
- `typescript-scripts init`
24+
- `init`
2025

2126
Initialises a repository for Typescript development. Currently it only checks that typescript
2227
is installed and creates a tsconfig.json file for you if it doesn't already exist.
2328

24-
- `typescript-scripts lint [options] [files/dirs]`
29+
- `lint [options] [files/dirs]`
2530

2631
Lints the specified files and directories. Defaults to checking for .js and .ts extensions.
2732

@@ -37,7 +42,7 @@ are using it within `package.json` simply write `typescript-scripts [script name
3742

3843
All the usual eslint flags can be passed to this script, they will be passed on to eslint.
3944

40-
- `typescript-scripts format`
45+
- `format`
4146

4247
Formats all the files in the repository using prettier.
4348

@@ -56,22 +61,22 @@ are using it within `package.json` simply write `typescript-scripts [script name
5661

5762
TODO - allow passing an argument to configure which files/folders should be formatted
5863

59-
- `typescript-scripts run [entrypoint]`
64+
- `run [entrypoint]`
6065

6166
Runs typescript files using `ts-node`. Useful for creating a run/start command which
6267
can be used to run a project for local development.
6368

6469
For example, add a script to your package.json called `dev` which runs
6570
`typescript-scripts run src/index.ts` (replace the path to your project entrypoint)
6671

67-
- `typescript-scripts test [files/directories/globs]`
72+
- `test [files/directories/globs]`
6873

6974
Runs tests with mocha using `ts-node` to execute Typescript files. Pass `--watch` to watch
7075
for changes and rerun the tests automatically.
7176

7277
Accepts all the usual [mocha CLI flags and options](https://mochajs.org/#command-line-usage).
7378

74-
- `typescript-scripts compile`
79+
- `compile`
7580

7681
Runs the `tsc` compiler.
7782

index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"use strict";
44

5-
import { compile, format, init, lint, run, test } from "./scripts";
5+
import { compile, format, help, init, lint, run, test } from "./scripts";
66

77
const args = process.argv.slice(2);
88
const scriptName = args[0];
@@ -30,6 +30,11 @@ switch (scriptName) {
3030
process.exit(0);
3131
break;
3232

33+
case "help":
34+
help();
35+
process.exit(0);
36+
break;
37+
3338
case "lint": {
3439
const status = lint();
3540
process.exit(status);
@@ -49,6 +54,6 @@ switch (scriptName) {
4954
}
5055

5156
default:
52-
console.log(`Unknown script '${scriptName}' called. Did you make a typo?`);
57+
help();
5358
process.exit(1);
5459
}

0 commit comments

Comments
 (0)