|
1 | 1 | /*
|
2 |
| - * Copyright 2016 DiffPlug |
| 2 | + * Copyright 2016-2024 DiffPlug |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 | package com.diffplug.spotless.npm;
|
17 | 17 |
|
18 | 18 | import java.io.File;
|
19 |
| -import java.io.IOException; |
20 | 19 | import java.io.Serializable;
|
21 | 20 | import java.util.Map;
|
22 | 21 | import java.util.TreeMap;
|
23 | 22 |
|
24 | 23 | import javax.annotation.Nullable;
|
25 | 24 |
|
26 | 25 | import com.diffplug.spotless.FileSignature;
|
27 |
| -import com.diffplug.spotless.ThrowingEx; |
28 |
| - |
29 |
| -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
30 | 26 |
|
31 | 27 | public class PrettierConfig implements Serializable {
|
32 | 28 |
|
33 | 29 | private static final long serialVersionUID = -8709340269833126583L;
|
34 | 30 |
|
35 |
| - @SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED") |
36 |
| - @Nullable |
37 |
| - private final transient File prettierConfigPath; |
38 |
| - |
39 |
| - @SuppressWarnings("unused") |
40 |
| - private final FileSignature prettierConfigPathSignature; |
| 31 | + private final FileSignature.Promised prettierConfigPathSignature; |
41 | 32 |
|
42 | 33 | private final TreeMap<String, Object> options;
|
43 | 34 |
|
44 | 35 | public PrettierConfig(@Nullable File prettierConfigPath, @Nullable Map<String, Object> options) {
|
45 |
| - try { |
46 |
| - this.prettierConfigPath = prettierConfigPath; |
47 |
| - this.prettierConfigPathSignature = prettierConfigPath != null ? FileSignature.signAsList(this.prettierConfigPath) : FileSignature.signAsList(); |
48 |
| - this.options = options == null ? new TreeMap<>() : new TreeMap<>(options); |
49 |
| - } catch (IOException e) { |
50 |
| - throw ThrowingEx.asRuntime(e); |
51 |
| - } |
| 36 | + this.prettierConfigPathSignature = prettierConfigPath == null ? null : FileSignature.promise(prettierConfigPath); |
| 37 | + this.options = options == null ? new TreeMap<>() : new TreeMap<>(options); |
52 | 38 | }
|
53 | 39 |
|
54 | 40 | @Nullable
|
55 | 41 | public File getPrettierConfigPath() {
|
56 |
| - return prettierConfigPath; |
| 42 | + return prettierConfigPathSignature == null ? null : prettierConfigPathSignature.get().getOnlyFile(); |
57 | 43 | }
|
58 | 44 |
|
59 | 45 | public Map<String, Object> getOptions() {
|
|
0 commit comments