Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workaround for NPM configuration cache (#2372) #2390

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This document is intended for Spotless developers.
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).

## [Unreleased]
### Fixed
* Node.JS-based tasks now work with the configuration cache ([#2372](https://github.com/diffplug/spotless/issues/2372))

## [3.0.1] - 2025-01-07
### Fixed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2024 DiffPlug
* Copyright 2020-2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

Expand All @@ -35,7 +36,9 @@ public NpmPathResolver(File explicitNpmExecutable, File explicitNodeExecutable,
this.explicitNpmExecutable = explicitNpmExecutable;
this.explicitNodeExecutable = explicitNodeExecutable;
this.explicitNpmrcFile = explicitNpmrcFile;
this.additionalNpmrcLocations = List.copyOf(additionalNpmrcLocations);
// We must not use an immutable list (e.g. List.copyOf) here, because immutable lists cannot be restored
// from Gradle’s serialisation. See https://github.com/diffplug/spotless/issues/2372
this.additionalNpmrcLocations = new ArrayList<>(additionalNpmrcLocations);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).

## [Unreleased]
### Fixed
* Node.JS-based tasks now work with the configuration cache ([#2372](https://github.com/diffplug/spotless/issues/2372))

## [7.0.1] - 2025-01-07
### Fixed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2024 DiffPlug
* Copyright 2016-2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -177,4 +177,15 @@ void useNpmNextToConfiguredNodePluginFromNodeGradlePlugin() throws Exception {
throw e;
}
}

@Test
public void supportsConfigurationCache() throws Exception {
setFile("build.gradle").toResource("com/diffplug/gradle/spotless/NpmTestsWithoutNpmInstallationTest_gradle_node_plugin_example_1.gradle");
setFile("test.ts").toResource("npm/prettier/config/typescript.dirty");
BuildResult spotlessApply = gradleRunner()
.withGradleVersion(GradleVersionSupport.STABLE_CONFIGURATION_CACHE.version)
.withArguments("--stacktrace", "--configuration-cache", "spotlessApply").build();
Assertions.assertThat(spotlessApply.getOutput()).contains("BUILD SUCCESSFUL");
assertFile("test.ts").sameAsResource("npm/prettier/config/typescript.configfile_prettier_2.clean");
}
}
Loading