Skip to content

Commit 6a9da62

Browse files
committed
Make the package executable
1 parent 49317f7 commit 6a9da62

3 files changed

Lines changed: 34 additions & 11 deletions

File tree

README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,37 @@ Available features from docker:
6464

6565
Formatting files or checking if they're already formatted is possible from the command line. This requires `node` and `npm`.
6666

67-
The extension has to be downloaded and compiled:
68-
- Locate the installed extension path or download the extension from Github.
67+
### Available features from the command line:
68+
- To prettify a file: `npm run --silent prettify-md < input.md`.
69+
- To prettify a file and save the output: `npm run --silent prettify-md < input.md > output.md`.
70+
- To check whether a file is prettyfied or not: `npm run --silent check-md < input.md`. This will fail with an exception and return code `1` if the file is not prettyfied.
71+
72+
> Note: the `--silent` switch sets the npm log level to silent, which is useful to hide the executed file name and concentrate on the actual output.
73+
74+
### Installation
75+
76+
To access the CLI, the extension can either be used from the Github sources, from the install VSCode extension or from npm.
77+
78+
#### Compiling from the source code
79+
80+
- Download the source code.
6981
- Go to the extension directory.
7082
- Run `npm install`.
7183
- Run `npm run compile`.
7284

73-
The typical location of the installed extension (your actual version might differ):
74-
- Windows: `%USERPROFILE%\.vscode\extensions\darkriszty.markdown-table-prettify-3.0.0`
75-
- macOS: `~/.vscode/extensions/darkriszty.markdown-table-prettify-3.0.0`
76-
- Linux: `~/.vscode/extensions/darkriszty.markdown-table-prettify-3.0.0`
85+
#### Using the already installed VSCode extension
7786

78-
Available features from the command line:
79-
- To prettify a file: `npm run --silent prettify-md < input.md`.
80-
- To prettify a file and save the output: `npm run --silent prettify-md < input.md > output.md`.
81-
- To check whether a file is prettyfied or not: `npm run --silent check-md < input.md`. This will fail with an exception and return code `1` if the file is not prettyfied.
87+
Locate the installed extension path. The typical location of the installed extension:
88+
- Windows: `%USERPROFILE%\.vscode\extensions\darkriszty.markdown-table-prettify-{version}`
89+
- macOS: `~/.vscode/extensions/darkriszty.markdown-table-prettify-{version}`
90+
- Linux: `~/.vscode/extensions/darkriszty.markdown-table-prettify-{version}`
8291

83-
> Note: the `--silent` switch sets the npm log level to silent, which is useful to hide the executed file name and concentrate on the actual output.
92+
#### Using it from npm
93+
94+
Install the npm package `npm install -g markdown-table-prettify`. Use `npx` to prettify files:
95+
- To prettify a file: `npx markdown-table-prettify < input.md`.
96+
- To prettify a file and save the output: `npx markdown-table-prettify < input.md > output.md`.
97+
- To check whether a file is prettyfied or not: `npx markdown-table-prettify --check < input.md`. This will fail with an exception and return code `1` if the file is not prettyfied.
8498

8599
## Known Issues
86100

cli/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
import { CliPrettify } from "./cliPrettify";
24
import { InputReader } from "./inputReader";
35

package.npm.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"main": "./cli/cliPrettify.js",
3+
"bin": {
4+
"markdown-table-prettify": "./cli/index.js"
5+
},
6+
"scripts": {
7+
"prettify-md": "node ./cli/index.js",
8+
"check-md": "node ./cli/index.js --check"
9+
},
310
"files": [
411
"/cli",
512
"/src"

0 commit comments

Comments
 (0)