Skip to content

Commit

Permalink
fix: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Dec 12, 2021
1 parent 9265c57 commit 85a53d1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 44 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
"!src/**/__exclude"
],
"bin": {
"ktlint": "resources/ktlint",
"run-ktlint": "dist/bin/run-ktlint.js",
"ktlint-all": "dist/bin/ktlint-all.js"
"ktlint": "resources/ktlint"
},
"publishConfig": {
"access": "public"
Expand Down
47 changes: 9 additions & 38 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## @naturalcycles/ktlint

> [ktlint](https://github.com/pinterest/ktlint), conveniently published to npm registry
> [ktlint](https://github.com/pinterest/ktlint) conveniently published to npm registry
[![npm](https://img.shields.io/npm/v/@naturalcycles/ktlint/latest.svg)](https://www.npmjs.com/package/@naturalcycles/ktlint)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
Expand All @@ -10,52 +10,23 @@ Current ktlint version: ~~0.43.2~~ `0.40.0`

Because `0.43.2` fails on Java 16+: https://github.com/pinterest/ktlint/issues/1195

# Features
# Quick start

## ktlint binary

Hosts `ktlint` binary in the npm registry.

So, you can install it as:
Install:

```shell
yarn add -D @naturalcycles/ktlint

# or with npm
npm i --save-dev @naturalcycles/ktlint
```

And access it as `node_modules/@naturalcycles/ktlint/resources/ktlint`.

E.g:

```shell
node_modules/@naturalcycles/ktlint/resources/ktlint --version
```

## run-ktlint

It exposes a `run-ktlint` CLI command, so you can run it like this (passing the arguments that you
would pass to ktlint):

```shell
yarn run-ktlint -F

# or

yarn run-ktlint "someFile.kt"
```

Test it with `yarn run-ktlint --version`

## ktlint-all
Run ktlint:

```shell
yarn ktlint-all
yarn ktlint --version
```

Equivalent of running `ktlint -F`.
No Step 3!

It also exposes a `ktlintAll` function in `index.js` for programmatic usage.
## API

It will throw an Error on non-zero return codes.
You can run `ktlint` programmatically via Node.js by calling `ktlintAll()` function exposed by this
module. It returns a Promise (rejects on non-zero code from `ktlint`, resolves on success).
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@
typescript "^4.0.2"

"@naturalcycles/dev-lib@^12.14.2":
version "12.14.2"
resolved "https://registry.yarnpkg.com/@naturalcycles/dev-lib/-/dev-lib-12.14.2.tgz#b4d91035b6c571cbdad52463afd3f5b2c9f426b4"
integrity sha512-yl9NJIBkJro59hs5mD2Dwsg9Tzkg50hVdxyL8/lfOdBtpUpJ0y/9a8f4Pxs6BBKOZLWZF2QMGcXAAd7yFb6mmA==
version "12.15.0"
resolved "https://registry.yarnpkg.com/@naturalcycles/dev-lib/-/dev-lib-12.15.0.tgz#48db14211823a0dd5eb89a03ec838f49be350605"
integrity sha512-ga0mNIw3nTWlbq3zq4STP+JVVrsKbJ1lXHyxGWieae++9j9uW/DxGanK2QOT9cQRiSxxNkI4YxpsP50fhup+NA==
dependencies:
"@commitlint/cli" "^15.0.0"
"@commitlint/config-conventional" "^15.0.0"
Expand Down

0 comments on commit 85a53d1

Please sign in to comment.