Skip to content

Commit

Permalink
integrating PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
simschla committed Sep 13, 2018
1 parent ade884a commit 807bf7b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
12 changes: 9 additions & 3 deletions lib/src/main/java/com/diffplug/spotless/JarState.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
import java.io.Serializable;
import java.net.URI;
import java.net.URL;
import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand All @@ -29,7 +35,7 @@
* Grabs a jar and its dependencies from maven,
* and makes it easy to access the collection in
* a classloader.
* <p>
*
* Serializes the full state of the jar, so it can
* catch changes in a SNAPSHOT version.
*/
Expand Down Expand Up @@ -79,7 +85,7 @@ URL[] jarUrls() {

/**
* Returns a classloader containing only the jars in this JarState.
* <p>
*
* The lifetime of the underlying cacheloader is controlled by {@link SpotlessCache}.
*/
public ClassLoader getClassLoader() {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/java/com/diffplug/spotless/npm/PlatformInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static OS normalizedOS() {
if (osNameProperty == null) {
throw new RuntimeException("No info about OS available, cannot decide which implementation of j2v8 to use");
}
final String normalizedOsName = osNameProperty.toLowerCase(Locale.ENGLISH);
final String normalizedOsName = osNameProperty.toLowerCase(Locale.ROOT);
if (normalizedOsName.contains("win")) {
return OS.WINDOWS;
}
Expand All @@ -51,7 +51,7 @@ static String normalizedArchName() {
if (osArchProperty == null) {
throw new RuntimeException("No info about ARCH available, cannot decide which implementation of j2v8 to use");
}
final String normalizedOsArch = osArchProperty.toLowerCase(Locale.ENGLISH);
final String normalizedOsArch = osArchProperty.toLowerCase(Locale.ROOT);

if (normalizedOsArch.contains("64")) {
return "x86_64";
Expand Down
4 changes: 0 additions & 4 deletions lib/src/main/java/com/diffplug/spotless/npm/Reflective.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ private Method method(Object target, Class<?> clazz, String methodName, Object[]
if (clazz.getSuperclass() != null) {
return method(target, clazz.getSuperclass(), methodName, parameters);
} else {
// try with primitives

throw new ReflectiveException("Could not find method " + methodName + " with parameters " + Arrays.toString(parameters) + " on object " + target, e);
}
}
Expand All @@ -112,8 +110,6 @@ private Method method(Object target, Class<?> clazz, String methodName, TypedVal
if (clazz.getSuperclass() != null) {
return method(target, clazz.getSuperclass(), methodName, parameters);
} else {
// try with primitives

throw new ReflectiveException("Could not find method " + methodName + " with parameters " + Arrays.toString(parameters) + " on object " + target, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ File configFile() {
}

String configFileEnabledOptionName() {
return this.configFileType.name().toLowerCase(Locale.ENGLISH);
return this.configFileType.name().toLowerCase(Locale.ROOT);
}

String configFileOptionName() {
Expand Down
12 changes: 8 additions & 4 deletions plugin-gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ spotless {
}
```

Spotless uses npm to install necessary packages locally. It runs tsfmt using [J2V8](https://github.com/eclipsesource/J2V8) internally after that.

<a name="prettier"></a>

## Applying [Prettier](https://prettier.io) to javascript | flow | typeScript | css | scss | less | jsx | graphQL | yaml | etc.
Expand Down Expand Up @@ -379,10 +381,9 @@ spotless {
format 'styling', {
target '**/*.css', '**/*.scss'
// or provide both (config options will win over configFile options)
prettier().configFile('/path-to/.prettierrc.yml')
// or provide both (config options will win over configFile options)
// or provide both (config options take precedence over configFile options)
prettier().config(['parser': 'postcss']).configFile('path-to/.prettierrc.yml')
}
}
Expand Down Expand Up @@ -411,15 +412,15 @@ Prettier can also be applied from within the [typescript config block](#typescri
spotless {
typescript {
// no parser or filepath needed
// -> will default to 'typesript' parser when used in the typescript block
// -> will default to 'typescript' parser when used in the typescript block
prettier()
}
}
```

### Prerequisite: prettier requires a working NodeJS version

prettier, like tsfmt, is based on NodeJS, so to use it, a working NodeJS installation (especially npm) is required on the host running spotless.
Prettier, like tsfmt, is based on NodeJS, so to use it, a working NodeJS installation (especially npm) is required on the host running spotless.
Spotless will try to auto-discover an npm installation. If that is not working for you, it is possible to directly configure the npm binary to use.

```gradle
Expand All @@ -429,6 +430,9 @@ spotless {
}
}
```

Spotless uses npm to install necessary packages locally. It runs prettier using [J2V8](https://github.com/eclipsesource/J2V8) internally after that.

<a name="license-header"></a>

## License header options
Expand Down

0 comments on commit 807bf7b

Please sign in to comment.