pinokiod 7.5.34 → 7.5.35
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/kernel/bin/conda.js +24 -6
- package/package.json +1 -1
- package/test/conda-bin.test.js +33 -1
package/kernel/bin/conda.js
CHANGED
|
@@ -118,6 +118,7 @@ function windowsCondaActivatePatchedBlock(eol) {
|
|
|
118
118
|
function windowsCondaActivatePatchRoutines(eol) {
|
|
119
119
|
return [
|
|
120
120
|
":PINOKIO_APPLY_CONDA_ENV",
|
|
121
|
+
"@ECHO OFF",
|
|
121
122
|
'@FOR /F "tokens=1,* delims==" %%A IN (%~1) DO (',
|
|
122
123
|
'@IF "%CONDA_DEBUG%" == "1" ECHO DEBUG: "%%A=%%B">&2',
|
|
123
124
|
'@IF "%%A"=="_CONDA_SCRIPT" (',
|
|
@@ -125,6 +126,7 @@ function windowsCondaActivatePatchRoutines(eol) {
|
|
|
125
126
|
'@ECHO ERROR: Activation script "%%B" failed with code %ERRORLEVEL%.>&2',
|
|
126
127
|
'@CALL :DELETE "%~1"',
|
|
127
128
|
'@CALL :DELETE "%~2"',
|
|
129
|
+
"@ECHO ON",
|
|
128
130
|
"@EXIT /B 4",
|
|
129
131
|
")",
|
|
130
132
|
') ELSE IF "%%B"=="" (',
|
|
@@ -135,6 +137,7 @@ function windowsCondaActivatePatchRoutines(eol) {
|
|
|
135
137
|
")",
|
|
136
138
|
'@CALL :DELETE "%~1"',
|
|
137
139
|
'@CALL :DELETE "%~2"',
|
|
140
|
+
"@ECHO ON",
|
|
138
141
|
"@EXIT /B 0",
|
|
139
142
|
"",
|
|
140
143
|
].join(eol)
|
|
@@ -245,20 +248,35 @@ class Conda {
|
|
|
245
248
|
}
|
|
246
249
|
throw error
|
|
247
250
|
}
|
|
251
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n"
|
|
252
|
+
const routineAnchor = `${eol}:: Routine to delete a temp file if CONDA_DEBUG is not set`
|
|
253
|
+
if (!content.includes(routineAnchor)) {
|
|
254
|
+
console.warn("Could not patch Conda CMD activation echo leak; missing _conda_activate.bat routine anchor")
|
|
255
|
+
return
|
|
256
|
+
}
|
|
248
257
|
if (content.includes(WINDOWS_CONDA_ACTIVATE_PINOKIO_MARKER)) {
|
|
258
|
+
if (content.includes(`${WINDOWS_CONDA_ACTIVATE_PINOKIO_MARKER}${eol}@ECHO OFF`)) {
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
const routineStart = content.indexOf(WINDOWS_CONDA_ACTIVATE_PINOKIO_MARKER)
|
|
262
|
+
const routineAnchorIndex = content.indexOf(routineAnchor, routineStart)
|
|
263
|
+
if (routineAnchorIndex < 0) {
|
|
264
|
+
console.warn("Could not update Conda CMD activation echo patch; missing _conda_activate.bat routine anchor")
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
const patched = [
|
|
268
|
+
content.slice(0, routineStart),
|
|
269
|
+
windowsCondaActivatePatchRoutines(eol),
|
|
270
|
+
content.slice(routineAnchorIndex + eol.length),
|
|
271
|
+
].join("")
|
|
272
|
+
await fs.promises.writeFile(activatePath, patched)
|
|
249
273
|
return
|
|
250
274
|
}
|
|
251
|
-
const eol = content.includes("\r\n") ? "\r\n" : "\n"
|
|
252
275
|
const originalBlock = windowsCondaActivateOriginalBlock(eol)
|
|
253
276
|
if (!content.includes(originalBlock)) {
|
|
254
277
|
console.warn("Could not patch Conda CMD activation echo leak; unexpected _conda_activate.bat")
|
|
255
278
|
return
|
|
256
279
|
}
|
|
257
|
-
const routineAnchor = `${eol}:: Routine to delete a temp file if CONDA_DEBUG is not set`
|
|
258
|
-
if (!content.includes(routineAnchor)) {
|
|
259
|
-
console.warn("Could not patch Conda CMD activation echo leak; missing _conda_activate.bat routine anchor")
|
|
260
|
-
return
|
|
261
|
-
}
|
|
262
280
|
const patched = content
|
|
263
281
|
.replace(originalBlock, windowsCondaActivatePatchedBlock(eol))
|
|
264
282
|
.replace(
|
package/package.json
CHANGED
package/test/conda-bin.test.js
CHANGED
|
@@ -275,11 +275,43 @@ test('Conda init patches Windows CMD activation echo leak idempotently', async (
|
|
|
275
275
|
assert.equal(await fs.readFile(activatePath, 'utf8'), patched)
|
|
276
276
|
assert.equal(patched.includes(WINDOWS_CONDA_ACTIVATE_ORIGINAL_BLOCK), false)
|
|
277
277
|
assert.match(patched, /ENDLOCAL & @CALL :PINOKIO_APPLY_CONDA_ENV "%%T" "%__conda_tmp%" & @GOTO :EOF/)
|
|
278
|
-
assert.match(patched, /:PINOKIO_APPLY_CONDA_ENV/)
|
|
278
|
+
assert.match(patched, /:PINOKIO_APPLY_CONDA_ENV\r\n@ECHO OFF/)
|
|
279
279
|
assert.match(patched, /@CALL "%%B" \|\| \(/)
|
|
280
|
+
assert.match(patched, /@ECHO ON\r\n@EXIT \/B 0/)
|
|
280
281
|
assert.match(patched, /:: Routine to delete a temp file if CONDA_DEBUG is not set/)
|
|
281
282
|
})
|
|
282
283
|
|
|
284
|
+
test('Conda init updates the earlier Windows CMD activation echo patch', async () => {
|
|
285
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-conda-cmd-activate-update-patch-'))
|
|
286
|
+
await fs.mkdir(path.join(root, 'bin', 'miniforge', 'conda-meta'), { recursive: true })
|
|
287
|
+
const oldPatch = WINDOWS_CONDA_ACTIVATE_SCRIPT
|
|
288
|
+
.replace(
|
|
289
|
+
WINDOWS_CONDA_ACTIVATE_ORIGINAL_BLOCK,
|
|
290
|
+
' ) ELSE ENDLOCAL & @CALL :PINOKIO_APPLY_CONDA_ENV "%%T" "%__conda_tmp%" & @GOTO :EOF'
|
|
291
|
+
)
|
|
292
|
+
.replace(
|
|
293
|
+
'\r\n:: Routine to delete a temp file if CONDA_DEBUG is not set',
|
|
294
|
+
[
|
|
295
|
+
'\r\n:PINOKIO_APPLY_CONDA_ENV',
|
|
296
|
+
'@FOR /F "tokens=1,* delims==" %%A IN (%~1) DO (',
|
|
297
|
+
'@IF "%CONDA_DEBUG%" == "1" ECHO DEBUG: "%%A=%%B">&2',
|
|
298
|
+
')',
|
|
299
|
+
'@CALL :DELETE "%~1"',
|
|
300
|
+
'@CALL :DELETE "%~2"',
|
|
301
|
+
'@EXIT /B 0',
|
|
302
|
+
':: Routine to delete a temp file if CONDA_DEBUG is not set',
|
|
303
|
+
].join('\r\n')
|
|
304
|
+
)
|
|
305
|
+
const activatePath = await seedWindowsCondaActivateScript(root, oldPatch)
|
|
306
|
+
const conda = createConda(createKernel(root))
|
|
307
|
+
|
|
308
|
+
await conda.init()
|
|
309
|
+
|
|
310
|
+
const patched = await fs.readFile(activatePath, 'utf8')
|
|
311
|
+
assert.match(patched, /:PINOKIO_APPLY_CONDA_ENV\r\n@ECHO OFF/)
|
|
312
|
+
assert.match(patched, /@ECHO ON\r\n@EXIT \/B 0/)
|
|
313
|
+
})
|
|
314
|
+
|
|
283
315
|
test('Conda init leaves unexpected Windows CMD activation script unchanged', async () => {
|
|
284
316
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-conda-cmd-activate-unexpected-'))
|
|
285
317
|
await fs.mkdir(path.join(root, 'bin', 'miniforge', 'conda-meta'), { recursive: true })
|