Skip to content

Commit cb81514

Browse files
authored
Reinstall node if necessary (fixes #863)
2 parents 397e36f + c3ad1f7 commit cb81514

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1414
* Update ktfmt from 0.21 to 0.24
1515
### Fixed
1616
* The `<url>` field in the maven POM is now set correctly ([#798](https://github.com/diffplug/spotless/issues/798))
17+
* Node is re-installed if some other build step removed it ([#863](https://github.com/diffplug/spotless/issues/863))
1718

1819
## [2.13.4] - 2021-04-21
1920
### Fixed

lib/src/main/java/com/diffplug/spotless/npm/NodeServerLayout.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 DiffPlug
2+
* Copyright 2020-2021 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.
@@ -46,4 +46,8 @@ File serveJsFile() {
4646
public File npmrcFile() {
4747
return npmrcFile;
4848
}
49+
50+
static File getBuildDirFromNodeModulesDir(File nodeModulesDir) {
51+
return nodeModulesDir.getParentFile();
52+
}
4953
}

lib/src/main/java/com/diffplug/spotless/npm/NpmFormatterStepStateBase.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 DiffPlug
2+
* Copyright 2016-2021 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.
@@ -85,7 +85,11 @@ private void runNpmInstall(File npmProjectDir) throws IOException {
8585
new NpmProcess(npmProjectDir, this.npmExecutable).install();
8686
}
8787

88-
protected ServerProcessInfo npmRunServer() throws ServerStartException {
88+
protected ServerProcessInfo npmRunServer() throws ServerStartException, IOException {
89+
if (!this.nodeModulesDir.exists()) {
90+
prepareNodeServer(NodeServerLayout.getBuildDirFromNodeModulesDir(this.nodeModulesDir));
91+
}
92+
8993
try {
9094
// The npm process will output the randomly selected port of the http server process to 'server.port' file
9195
// so in order to be safe, remove such a file if it exists before starting.

plugin-gradle/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
77
* Update ktfmt from 0.21 to 0.24
88
### Fixed
99
* The `<url>` field in the maven POM is now set correctly ([#798](https://github.com/diffplug/spotless/issues/798))
10+
* Node is re-installed if some other build step removed it ([#863](https://github.com/diffplug/spotless/issues/863))
1011

1112
## [5.12.4] - 2021-04-21
1213
### Fixed

plugin-maven/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
44

55
## [Unreleased]
6+
### Fixed
7+
* Node is re-installed if some other build step removed it ([#863](https://github.com/diffplug/spotless/issues/863))
68

79
## [2.11.0] - 2021-05-03
810
### Added

0 commit comments

Comments
 (0)