Skip to content

Commit ed95a7c

Browse files
committed
1480: add configuration to readme
1 parent cd84167 commit ed95a7c

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

plugin-gradle/README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Spotless supports all of Gradle's built-in performance features (incremental bui
6767
- [Javascript](#javascript) ([prettier](#prettier), [ESLint](#eslint-javascript))
6868
- [JSON](#json)
6969
- Multiple languages
70-
- [Prettier](#prettier) ([plugins](#prettier-plugins), [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection))
70+
- [Prettier](#prettier) ([plugins](#prettier-plugins), [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection), [caching `npm install` results](#caching-results-of-npm-install))
7171
- javascript, jsx, angular, vue, flow, typescript, css, less, scss, html, json, graphql, markdown, ymaml
7272
- [clang-format](#clang-format)
7373
- c, c++, c#, objective-c, protobuf, javascript, java
@@ -630,7 +630,8 @@ spotless {
630630
631631
**Prerequisite: tsfmt requires a working NodeJS version**
632632
633-
For details, see the [npm detection](#npm-detection) and [`.npmrc` detection](#npmrc-detection) sections of prettier, which apply also to tsfmt.
633+
For details, see the [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection) and [caching results of `npm install`](#caching-results-of-npm-install) sections of prettier, which apply also to tsfmt.
634+
634635
635636
### ESLint (Typescript)
636637
@@ -678,7 +679,7 @@ spotless {
678679
679680
**Prerequisite: ESLint requires a working NodeJS version**
680681
681-
For details, see the [npm detection](#npm-detection) and [`.npmrc` detection](#npmrc-detection) sections of prettier, which apply also to ESLint.
682+
For details, see the [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection) and [caching results of `npm install`](#caching-results-of-npm-install) sections of prettier, which apply also to ESLint.
682683
683684
## Javascript
684685
@@ -742,7 +743,7 @@ spotless {
742743
743744
**Prerequisite: ESLint requires a working NodeJS version**
744745
745-
For details, see the [npm detection](#npm-detection) and [`.npmrc` detection](#npmrc-detection) sections of prettier, which apply also to ESLint.
746+
For details, see the [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection) and [caching results of `npm install`](#caching-results-of-npm-install) sections of prettier, which apply also to ESLint.
746747
747748
## JSON
748749
@@ -926,8 +927,6 @@ node- and npm-binaries dynamically installed by this plugin. See
926927
[this](https://github.com/diffplug/spotless/blob/main/plugin-gradle/src/test/resources/com/diffplug/gradle/spotless/NpmTestsWithoutNpmInstallationTest_gradle_node_plugin_example_1.gradle)
927928
or [this](https://github.com/diffplug/spotless/blob/main/plugin-gradle/src/test/resources/com/diffplug/gradle/spotless/NpmTestsWithoutNpmInstallationTest_gradle_node_plugin_example_2.gradle) example.
928929
929-
```gradle
930-
931930
### `.npmrc` detection
932931
933932
Spotless picks up npm configuration stored in a `.npmrc` file either in the project directory or in your user home.
@@ -940,6 +939,22 @@ spotless {
940939
prettier().npmrc("$projectDir/config/.npmrc").config(...)
941940
```
942941
942+
### Caching results of `npm install`
943+
944+
Spotless uses `npm` behind the scenes to install `prettier`. This can be a slow process, especially if you are using a slow internet connection or
945+
if you need large plugins. You can instruct spotless to cache the results of the `npm install` calls, so that for the next installation,
946+
it will not need to download the packages again, but instead reuse the cached version.
947+
948+
```gradle
949+
spotless {
950+
typescript {
951+
prettier().npmInstallCache() // will use the default cache directory (the build-directory of the respective module)
952+
prettier().npmInstallCache("${rootProject.rootDir}/.gradle/spotless-npm-cache") // will use the specified directory (creating it if not existing)
953+
```
954+
955+
Depending on your filesystem and the location of the cache directory, spotless will use hardlinks when caching the npm packages. If that is not
956+
possible, it will fall back to copying the files.
957+
943958
## clang-format
944959
945960
[homepage](https://clang.llvm.org/docs/ClangFormat.html). [changelog](https://releases.llvm.org/download.html). `clang-format` is a formatter for c, c++, c#, objective-c, protobuf, javascript, and java. You can use clang-format in any language-specific format, but usually you will be creating a generic format.

plugin-maven/README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ user@machine repo % mvn spotless:check
5454
- [JSON](#json)
5555
- [YAML](#yaml)
5656
- Multiple languages
57-
- [Prettier](#prettier) ([plugins](#prettier-plugins), [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection))
57+
- [Prettier](#prettier) ([plugins](#prettier-plugins), [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection), [caching `npm install` results](#caching-results-of-npm-install))
5858
- [eclipse web tools platform](#eclipse-web-tools-platform)
5959
- **Language independent**
6060
- [Generic steps](#generic-steps)
@@ -731,7 +731,7 @@ The auto-discovery of config files (up the file tree) will not work when using t
731731

732732
**Prerequisite: tsfmt requires a working NodeJS version**
733733

734-
For details, see the [npm detection](#npm-detection) and [`.npmrc` detection](#npmrc-detection) sections of prettier, which apply also to tsfmt.
734+
For details, see the [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection) and [caching results of `npm install`](#caching-results-of-npm-install) sections of prettier, which apply also to tsfmt.
735735

736736
### ESLint (typescript)
737737

@@ -787,7 +787,7 @@ reference to a `tsconfig.json` is required.
787787

788788
**Prerequisite: ESLint requires a working NodeJS version**
789789

790-
For details, see the [npm detection](#npm-detection) and [`.npmrc` detection](#npmrc-detection) sections of prettier, which apply also to ESLint.
790+
For details, see the [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection) and [caching results of `npm install`](#caching-results-of-npm-install) sections of prettier, which apply also to ESLint.
791791

792792

793793
## Javascript
@@ -863,7 +863,7 @@ The configuration is very similar to the [ESLint (Typescript)](#eslint-typescrip
863863

864864
**Prerequisite: ESLint requires a working NodeJS version**
865865

866-
For details, see the [npm detection](#npm-detection) and [`.npmrc` detection](#npmrc-detection) sections of prettier, which apply also to ESLint.
866+
For details, see the [npm detection](#npm-detection), [`.npmrc` detection](#npmrc-detection) and [caching results of `npm install`](#caching-results-of-npm-install) sections of prettier, which apply also to ESLint.
867867

868868
## JSON
869869

@@ -1113,6 +1113,21 @@ Alternatively you can supply spotless with a location of the `.npmrc` file to us
11131113
<npmrc>/usr/local/shared/.npmrc</npmrc>
11141114
```
11151115

1116+
### Caching results of `npm install`
1117+
1118+
Spotless uses `npm` behind the scenes to install `prettier`. This can be a slow process, especially if you are using a slow internet connection or
1119+
if you need large plugins. You can instruct spotless to cache the results of the `npm install` calls, so that for the next installation,
1120+
it will not need to download the packages again, but instead reuse the cached version.
1121+
1122+
```xml
1123+
<prettier>
1124+
<npmInstallCache>true</npmInstallCache> <!-- will use the default cache directory (the `target`-directory) -->
1125+
<npmInstallCache>/usr/local/shared/.spotless-npm-install-cache</npmInstallCache> <!-- will use the specified directory (creating it if not existing) -->
1126+
```
1127+
1128+
Depending on your filesystem and the location of the cache directory, spotless will use hardlinks when caching the npm packages. If that is not
1129+
possible, it will fall back to copying the files.
1130+
11161131
<a name="applying-eclipse-wtp-to-css--html--etc"></a>
11171132

11181133
## Eclipse web tools platform

0 commit comments

Comments
 (0)