@aikidosec/safe-chain 1.0.19 → 1.0.20

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": "@aikidosec/safe-chain",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "scripts": {
5
5
  "test": "node --test --experimental-test-module-mocks 'src/**/*.spec.js'",
6
6
  "test:watch": "node --test --watch --experimental-test-module-mocks 'src/**/*.spec.js'",
@@ -14,6 +14,7 @@ export function createPnpmPackageManager() {
14
14
  matchesCommand(args, "upgrade") ||
15
15
  matchesCommand(args, "up") ||
16
16
  matchesCommand(args, "install") ||
17
+ matchesCommand(args, "i") ||
17
18
  // dlx does not always come in the first position
18
19
  // eg: pnpm --package=yo --package=generator-webapp dlx yo webapp
19
20
  // documentation: https://pnpm.io/cli/dlx#--package-name
@@ -3,7 +3,8 @@ import {
3
3
  doesExecutableExistOnSystem,
4
4
  removeLinesMatchingPattern,
5
5
  } from "../helpers.js";
6
- import { execSync } from "child_process";
6
+ import { execSync, spawnSync } from "child_process";
7
+ import * as os from "os";
7
8
 
8
9
  const shellName = "Bash";
9
10
  const executableName = "bash";
@@ -43,10 +44,12 @@ function setup() {
43
44
 
44
45
  function getStartupFile() {
45
46
  try {
46
- return execSync(startupFileCommand, {
47
+ var path = execSync(startupFileCommand, {
47
48
  encoding: "utf8",
48
49
  shell: executableName,
49
50
  }).trim();
51
+
52
+ return windowsFixPath(path);
50
53
  } catch (error) {
51
54
  throw new Error(
52
55
  `Command failed: ${startupFileCommand}. Error: ${error.message}`
@@ -54,6 +57,50 @@ function getStartupFile() {
54
57
  }
55
58
  }
56
59
 
60
+ function windowsFixPath(path) {
61
+ try {
62
+ if (os.platform() !== "win32") {
63
+ return path;
64
+ }
65
+
66
+ // On windows cygwin bash, paths are returned in format /c/user/..., but we need it in format C:\user\...
67
+ // To convert, the cygpath -w command can be used to convert to the desired format.
68
+ // Cygpath only exists on Cygwin, so we first check if the command is available.
69
+ // If it is, we use it to convert the path.
70
+ if (hasCygpath()) {
71
+ return cygpathw(path);
72
+ }
73
+
74
+ return path;
75
+ } catch {
76
+ return path;
77
+ }
78
+ }
79
+
80
+ function hasCygpath() {
81
+ try {
82
+ var result = spawnSync("where", ["cygpath"], { shell: executableName });
83
+ return result.status === 0;
84
+ } catch {
85
+ return false;
86
+ }
87
+ }
88
+
89
+ function cygpathw(path) {
90
+ try {
91
+ var result = spawnSync("cygpath", ["-w", path], {
92
+ encoding: "utf8",
93
+ shell: executableName,
94
+ });
95
+ if (result.status === 0) {
96
+ return result.stdout.trim();
97
+ }
98
+ return path;
99
+ } catch {
100
+ return path;
101
+ }
102
+ }
103
+
57
104
  export default {
58
105
  name: shellName,
59
106
  isInstalled,