@techsologic/unolock-agent 0.1.43 → 0.1.44

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.
@@ -4,24 +4,24 @@
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
 
7
- const {
8
- PACKAGE_VERSION,
9
- binaryUrl,
10
- ensureDir,
11
- ensureExecutable,
12
- fetchToFile,
13
- installedBinaryPath,
14
- } = require("./unolock-agent-common");
7
+ const common = require("./unolock-agent-common");
15
8
 
16
- async function main() {
17
- const dest = installedBinaryPath();
18
- if (fs.existsSync(dest)) {
19
- ensureExecutable(dest);
20
- return;
9
+ async function installBinary(options = {}) {
10
+ const fsImpl = options.fsImpl || fs;
11
+ const commonImpl = options.commonImpl || common;
12
+ const dest = commonImpl.installedBinaryPath();
13
+ if (fsImpl.existsSync(dest)) {
14
+ fsImpl.unlinkSync(dest);
21
15
  }
22
- ensureDir(path.dirname(dest));
23
- process.stderr.write(`Installing UnoLock agent ${PACKAGE_VERSION} for ${process.platform}/${process.arch}...\n`);
24
- await fetchToFile(binaryUrl(PACKAGE_VERSION), dest);
16
+ commonImpl.ensureDir(path.dirname(dest));
17
+ process.stderr.write(
18
+ `Installing UnoLock agent ${commonImpl.PACKAGE_VERSION} for ${process.platform}/${process.arch}...\n`,
19
+ );
20
+ await commonImpl.fetchToFile(commonImpl.binaryUrl(commonImpl.PACKAGE_VERSION), dest);
21
+ }
22
+
23
+ async function main() {
24
+ await installBinary();
25
25
  }
26
26
 
27
27
  if (require.main === module) {
@@ -30,3 +30,8 @@ if (require.main === module) {
30
30
  process.exit(1);
31
31
  });
32
32
  }
33
+
34
+ module.exports = {
35
+ installBinary,
36
+ main,
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techsologic/unolock-agent",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "description": "UnoLock Agent CLI and local runtime",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://unolock.ai",