You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Prerequisite: tsfmt requires a working NodeJS version**
632
632
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
+
634
635
635
636
### ESLint (Typescript)
636
637
@@ -678,7 +679,7 @@ spotless {
678
679
679
680
**Prerequisite: ESLint requires a working NodeJS version**
680
681
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.
682
683
683
684
## Javascript
684
685
@@ -742,7 +743,7 @@ spotless {
742
743
743
744
**Prerequisite: ESLint requires a working NodeJS version**
744
745
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.
746
747
747
748
## JSON
748
749
@@ -926,8 +927,6 @@ node- and npm-binaries dynamically installed by this plugin. See
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.
928
929
929
-
```gradle
930
-
931
930
### `.npmrc` detection
932
931
933
932
Spotless picks up npm configuration stored in a `.npmrc` file either in the project directory or in your user home.
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
+
943
958
## clang-format
944
959
945
960
[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.
-[eclipse web tools platform](#eclipse-web-tools-platform)
59
59
-**Language independent**
60
60
-[Generic steps](#generic-steps)
@@ -731,7 +731,7 @@ The auto-discovery of config files (up the file tree) will not work when using t
731
731
732
732
**Prerequisite: tsfmt requires a working NodeJS version**
733
733
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.
735
735
736
736
### ESLint (typescript)
737
737
@@ -787,7 +787,7 @@ reference to a `tsconfig.json` is required.
787
787
788
788
**Prerequisite: ESLint requires a working NodeJS version**
789
789
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.
791
791
792
792
793
793
## Javascript
@@ -863,7 +863,7 @@ The configuration is very similar to the [ESLint (Typescript)](#eslint-typescrip
863
863
864
864
**Prerequisite: ESLint requires a working NodeJS version**
865
865
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.
867
867
868
868
## JSON
869
869
@@ -1113,6 +1113,21 @@ Alternatively you can supply spotless with a location of the `.npmrc` file to us
1113
1113
<npmrc>/usr/local/shared/.npmrc</npmrc>
1114
1114
```
1115
1115
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
0 commit comments