@package-pal/cli 0.0.14 → 0.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@package-pal/cli",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "CLI tool exposing core PackagePal functionality.",
5
5
  "keywords": [
6
6
  "package",
@@ -15,39 +15,47 @@ export const linkExistingBinary = (
15
15
  const isWin = platform === 'win32';
16
16
 
17
17
  /**
18
- * @param {string} method
18
+ * @param {string | undefined} method
19
19
  */
20
20
  const verifyLinked = (method) => {
21
21
  if (!existsSync(outputBinPath)) {
22
- throw new Error(`Expected link not found after ${method}: '${outputBinPath}'.`);
22
+ throw new Error(`Expected link not found${method ? ` after ${method}` : ''}: '${outputBinPath}'.`);
23
23
  }
24
24
  };
25
25
 
26
- try {
27
- if (!isWin) {
26
+ const errs = [];
27
+
28
+ if (!isWin) {
29
+ try {
28
30
  symlinkSync(targetBinPath, outputBinPath);
29
31
  verifyLinked('symlinkSync');
32
+
30
33
  return;
34
+ } catch (eSymlinkSync) {
35
+ errs.push(eSymlinkSync);
31
36
  }
32
- } catch (eSym) {
37
+ }
38
+
39
+ try {
40
+ linkSync(targetBinPath, outputBinPath);
41
+ verifyLinked('linkSync');
42
+ } catch (eLinkSync) {
43
+ errs.push(eLinkSync);
44
+
33
45
  try {
34
- linkSync(targetBinPath, outputBinPath);
35
- verifyLinked('linkSync');
36
- } catch (eLink) {
37
- try {
38
- copyFileSync(targetBinPath, outputBinPath);
39
- verifyLinked('copyFileSync');
40
- } catch (eCopy) {
41
- const cause = [
42
- eSym,
43
- eLink,
44
- eCopy,
45
- ].filter(Boolean);
46
- throw new Error(`Failed to link to or copy target binary '${targetBinPath}'.`, { cause });
47
- }
46
+ copyFileSync(targetBinPath, outputBinPath);
47
+ verifyLinked('copyFileSync');
48
+ } catch (eCopyFileSync) {
49
+ errs.push(eCopyFileSync);
48
50
  }
49
51
  }
50
52
 
53
+ try {
54
+ verifyLinked(undefined);
55
+ } catch {
56
+ throw new Error('Unable to link CLI binary.', { cause: errs });
57
+ }
58
+
51
59
  console.info(`Successfully linked binary: '${outputBinPath}' → '${targetBinPath}'.`);
52
60
 
53
61
  if (isWin) {