Skip to content

Commit c35888a

Browse files
committed
chore: try reproducing issue 1984
1 parent 7262511 commit c35888a

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PrettierIntegrationTest.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -358,6 +358,54 @@ void autodetectNpmrcFileConfig(String prettierVersion) throws IOException {
358358
Assertions.assertThat(spotlessApply.getOutput()).containsPattern("Running npm command.*npm install.* failed with exit code: 1");
359359
}
360360

361+
@ParameterizedTest(name = "{index}: verifyCleanAndSpotlessWorks with prettier {0}")
362+
@ValueSource(strings = {PRETTIER_VERSION_2, PRETTIER_VERSION_3})
363+
void verifyCleanAndSpotlessWorks(String prettierVersion) throws IOException {
364+
setFile("build.gradle").toLines(
365+
"plugins {",
366+
" id 'com.diffplug.spotless'",
367+
"}",
368+
"repositories { mavenCentral() }",
369+
"def prettierConfig = [:]",
370+
"prettierConfig['printWidth'] = 20",
371+
"prettierConfig['parser'] = 'typescript'",
372+
"spotless {",
373+
" format 'mytypescript', {",
374+
" target 'test.ts'",
375+
" prettier('" + prettierVersion + "').config(prettierConfig)",
376+
" }",
377+
"}");
378+
setFile("test.ts").toResource("npm/prettier/config/typescript.dirty");
379+
final BuildResult spotlessApply = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build();
380+
Assertions.assertThat(spotlessApply.getOutput()).contains("BUILD SUCCESSFUL");
381+
final BuildResult spotlessApply2 = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build();
382+
Assertions.assertThat(spotlessApply2.getOutput()).contains("BUILD SUCCESSFUL");
383+
}
384+
385+
@ParameterizedTest(name = "{index}: verifyCleanAndSpotlessWithNpmInstallCacheWorks with prettier {0}")
386+
@ValueSource(strings = {PRETTIER_VERSION_2, PRETTIER_VERSION_3})
387+
void verifyCleanAndSpotlessWithNpmInstallCacheWorks(String prettierVersion) throws IOException {
388+
setFile("build.gradle").toLines(
389+
"plugins {",
390+
" id 'com.diffplug.spotless'",
391+
"}",
392+
"repositories { mavenCentral() }",
393+
"def prettierConfig = [:]",
394+
"prettierConfig['printWidth'] = 20",
395+
"prettierConfig['parser'] = 'typescript'",
396+
"spotless {",
397+
" format 'mytypescript', {",
398+
" target 'test.ts'",
399+
" prettier('" + prettierVersion + "').npmInstallCache().config(prettierConfig)",
400+
" }",
401+
"}");
402+
setFile("test.ts").toResource("npm/prettier/config/typescript.dirty");
403+
final BuildResult spotlessApply = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build();
404+
Assertions.assertThat(spotlessApply.getOutput()).contains("BUILD SUCCESSFUL");
405+
final BuildResult spotlessApply2 = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build();
406+
Assertions.assertThat(spotlessApply2.getOutput()).contains("BUILD SUCCESSFUL");
407+
}
408+
361409
@ParameterizedTest(name = "{index}: autodetectNpmrcFileConfig with prettier {0}")
362410
@ValueSource(strings = {PRETTIER_VERSION_2, PRETTIER_VERSION_3})
363411
void pickupNpmrcFileConfig(String prettierVersion) throws IOException {

0 commit comments

Comments
 (0)