dprint 0.38.2 → 0.38.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/install.js ADDED
@@ -0,0 +1,4 @@
1
+ // @ts-check
2
+ "use strict";
3
+
4
+ require("./install_api").runInstall();
package/install_api.js CHANGED
@@ -33,9 +33,10 @@ module.exports = {
33
33
  throw new Error("Throwing for testing purposes.");
34
34
  }
35
35
 
36
- // in order to make things faster the next time we run, copy the
37
- // executable into the dprint package folder
38
- fs.copyFileSync(sourceExecutablePath, targetExecutablePath);
36
+ // in order to make things faster the next time we run and to allow the
37
+ // dprint vscode extension to easily pick this up, copy the executable
38
+ // into the dprint package folder
39
+ atomicCopyFileSync(sourceExecutablePath, targetExecutablePath);
39
40
  if (os.platform() !== "win32") {
40
41
  // chomd +x
41
42
  chmodX(targetExecutablePath);
@@ -138,3 +139,15 @@ function getLinuxFamily() {
138
139
  }
139
140
  }
140
141
  }
142
+
143
+ /**
144
+ * @param sourcePath {string}
145
+ * @param destinationPath {string}
146
+ */
147
+ function atomicCopyFileSync(sourcePath, destinationPath) {
148
+ const crypto = require("crypto");
149
+ const rand = crypto.randomBytes(4).toString("hex");
150
+ const tempFilePath = destinationPath + "." + rand;
151
+ fs.copyFileSync(sourcePath, tempFilePath);
152
+ fs.renameSync(tempFilePath, destinationPath);
153
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dprint",
3
- "version": "0.38.2",
3
+ "version": "0.38.3",
4
4
  "description": "Pluggable and configurable code formatting platform written in Rust.",
5
5
  "bin": "bin.js",
6
6
  "repository": {
@@ -18,12 +18,15 @@
18
18
  },
19
19
  "homepage": "https://github.com/dprint/dprint#readme",
20
20
  "preferUnplugged": true,
21
+ "scripts": {
22
+ "postinstall": "node ./install.js"
23
+ },
21
24
  "optionalDependencies": {
22
- "@dprint/win32-x64": "0.38.2",
23
- "@dprint/darwin-x64": "0.38.2",
24
- "@dprint/darwin-arm64": "0.38.2",
25
- "@dprint/linux-x64-glibc": "0.38.2",
26
- "@dprint/linux-x64-musl": "0.38.2",
27
- "@dprint/linux-arm64-glibc": "0.38.2"
25
+ "@dprint/win32-x64": "0.38.3",
26
+ "@dprint/darwin-x64": "0.38.3",
27
+ "@dprint/darwin-arm64": "0.38.3",
28
+ "@dprint/linux-x64-glibc": "0.38.3",
29
+ "@dprint/linux-x64-musl": "0.38.3",
30
+ "@dprint/linux-arm64-glibc": "0.38.3"
28
31
  }
29
32
  }