looply-cli 0.5.6 → 0.5.7

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.
@@ -117,17 +117,37 @@ function encode(result, options) {
117
117
  return enc === 'buffer' ? Buffer.from(result, 'utf8') : result;
118
118
  }
119
119
 
120
+ /**
121
+ * 🔴 A REALPATH THAT LEAVES THE MAPPED DRIVE. Gate steps run from a drive letter
122
+ * mapped to the checkout (`DefineDosDevice`, see appcontainer.ps1). On C: the
123
+ * native realpath fails (EPERM) and the lenient walk keeps the mapped letter.
124
+ * For a checkout on D: (`D:\looply-home\workspaces`, 2026-10-16) it SUCCEEDS
125
+ * and answers the volume's own path, `Z:\web\x` → `D:\looply-home\…\web\x`,
126
+ * which the container then cannot open: Vitest failed every file with "Failed
127
+ * to load url Z:/web/test-setup.ts (resolved id: D:/…)". So a native answer on
128
+ * a different drive letter from its input is replaced by the lenient walk, which
129
+ * still follows every link the container can see.
130
+ */
131
+ function leftItsDrive(path, input, output) {
132
+ const drive = /^[A-Za-z]:[\\/]/;
133
+ const a = path.resolve(toPathString(input));
134
+ const b = toPathString(output);
135
+ return drive.test(a) && drive.test(b) && a[0].toLowerCase() !== b[0].toLowerCase();
136
+ }
137
+
120
138
  function installRealpath(fs, path) {
121
139
  const lenient = (p, options) => encode(lenientRealpath(fs, path, toPathString(p)), options);
122
140
 
123
141
  const wrapSync = (orig) =>
124
142
  function realpathSync(p, options) {
143
+ let out;
125
144
  try {
126
- return orig.call(fs, p, options);
145
+ out = orig.call(fs, p, options);
127
146
  } catch (e) {
128
147
  if (!denied(e)) throw e;
129
148
  return lenient(p, options);
130
149
  }
150
+ return leftItsDrive(path, p, out) ? lenient(p, options) : out;
131
151
  };
132
152
  const wrapCallback = (orig) =>
133
153
  function realpath(p, options, callback) {
@@ -136,7 +156,8 @@ function installRealpath(fs, path) {
136
156
  options = undefined;
137
157
  }
138
158
  orig.call(fs, p, options, (e, resolved) => {
139
- if (!denied(e)) return callback(e, resolved);
159
+ if (!e && !leftItsDrive(path, p, resolved)) return callback(null, resolved);
160
+ if (e && !denied(e)) return callback(e, resolved);
140
161
  let out;
141
162
  try {
142
163
  out = lenient(p, options);
@@ -156,12 +177,14 @@ function installRealpath(fs, path) {
156
177
 
157
178
  const origPromise = fs.promises.realpath;
158
179
  fs.promises.realpath = async function realpath(p, options) {
180
+ let out;
159
181
  try {
160
- return await origPromise.call(fs.promises, p, options);
182
+ out = await origPromise.call(fs.promises, p, options);
161
183
  } catch (e) {
162
184
  if (!denied(e)) throw e;
163
185
  return lenient(p, options);
164
186
  }
187
+ return leftItsDrive(path, p, out) ? lenient(p, options) : out;
165
188
  };
166
189
  }
167
190
 
@@ -525,6 +548,6 @@ function install() {
525
548
  return true;
526
549
  }
527
550
 
528
- module.exports = { install, lenientRealpath, normaliseStdio, IPC_REFUSAL, LOCAL_PIPE_PREFIX };
551
+ module.exports = { install, lenientRealpath, leftItsDrive, normaliseStdio, IPC_REFUSAL, LOCAL_PIPE_PREFIX };
529
552
 
530
553
  if (process.env.LOOPLY_CONTAINED_NODE === '1') install();