pinokiod 7.1.6 → 7.1.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.
- package/kernel/index.js +12 -15
- package/kernel/shell.js +8 -4
- package/kernel/shells.js +21 -0
- package/package.json +1 -1
package/kernel/index.js
CHANGED
|
@@ -834,7 +834,6 @@ class Kernel {
|
|
|
834
834
|
try {
|
|
835
835
|
const result = execSync(`where ${name}`, { env: this.envs, encoding: "utf-8" })
|
|
836
836
|
const lines = result.trim().split("\r\n")
|
|
837
|
-
console.log({ result, lines })
|
|
838
837
|
if (pattern) {
|
|
839
838
|
let match = null
|
|
840
839
|
for(let line of lines) {
|
|
@@ -843,10 +842,8 @@ class Kernel {
|
|
|
843
842
|
matches[2] += "g" // if g option is not included, include it (need it for matchAll)
|
|
844
843
|
}
|
|
845
844
|
let re = new RegExp(matches[1], matches[2])
|
|
846
|
-
console.log("testing", { line, pattern, re })
|
|
847
845
|
if (re.test(line)) {
|
|
848
846
|
match = line
|
|
849
|
-
console.log("matched", { line })
|
|
850
847
|
break
|
|
851
848
|
}
|
|
852
849
|
}
|
|
@@ -859,7 +856,6 @@ class Kernel {
|
|
|
859
856
|
}
|
|
860
857
|
}
|
|
861
858
|
} catch (e) {
|
|
862
|
-
console.log("Error", e)
|
|
863
859
|
return null
|
|
864
860
|
}
|
|
865
861
|
} else {
|
|
@@ -991,6 +987,18 @@ class Kernel {
|
|
|
991
987
|
this.template = new Template()
|
|
992
988
|
try {
|
|
993
989
|
if (this.homedir) {
|
|
990
|
+
// Initialize template state before async startup tasks update or render it.
|
|
991
|
+
await this.template.init({
|
|
992
|
+
kernel: this,
|
|
993
|
+
system,
|
|
994
|
+
platform: this.platform,
|
|
995
|
+
arch: this.arch,
|
|
996
|
+
vram: this.vram,
|
|
997
|
+
ram: this.ram,
|
|
998
|
+
proxy: (port) => {
|
|
999
|
+
return this.api.get_proxy_url("/proxy", port)
|
|
1000
|
+
},
|
|
1001
|
+
})
|
|
994
1002
|
|
|
995
1003
|
// 0. create homedir
|
|
996
1004
|
let home_exists = await this.exists(this.homedir)
|
|
@@ -1164,17 +1172,6 @@ class Kernel {
|
|
|
1164
1172
|
//await this.shell.init()
|
|
1165
1173
|
|
|
1166
1174
|
if (this.homedir) {
|
|
1167
|
-
await this.template.init({
|
|
1168
|
-
kernel: this,
|
|
1169
|
-
system,
|
|
1170
|
-
platform: this.platform,
|
|
1171
|
-
arch: this.arch,
|
|
1172
|
-
vram: this.vram,
|
|
1173
|
-
ram: this.ram,
|
|
1174
|
-
proxy: (port) => {
|
|
1175
|
-
return this.api.get_proxy_url("/proxy", port)
|
|
1176
|
-
},
|
|
1177
|
-
})
|
|
1178
1175
|
// setTimeout(() => {
|
|
1179
1176
|
// this.refresh()
|
|
1180
1177
|
// }, 3000)
|
package/kernel/shell.js
CHANGED
|
@@ -174,7 +174,7 @@ class Shell {
|
|
|
174
174
|
// fall back to whichever casing exists so we don't end up writing to an undefined key
|
|
175
175
|
this.env[PATH_KEY] = this.env.Path || this.env.PATH || this.env.path;
|
|
176
176
|
}
|
|
177
|
-
if (this.
|
|
177
|
+
if (this.isCmdShell()) {
|
|
178
178
|
// ignore
|
|
179
179
|
} else {
|
|
180
180
|
this.env[PATH_KEY]= this.kernel.shellpath || [
|
|
@@ -253,6 +253,10 @@ class Shell {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
+
isCmdShell(shellName=this.shell) {
|
|
257
|
+
const name = (shellName || '').toLowerCase()
|
|
258
|
+
return name.includes('cmd.exe') || name === 'cmd'
|
|
259
|
+
}
|
|
256
260
|
async start(params, ondata) {
|
|
257
261
|
this.ondata = ondata
|
|
258
262
|
if (this.nudgeRestoreTimer) {
|
|
@@ -604,7 +608,7 @@ class Shell {
|
|
|
604
608
|
|
|
605
609
|
// Log before resolving
|
|
606
610
|
this._log(buf, cleaned)
|
|
607
|
-
if (this.
|
|
611
|
+
if (this.isCmdShell()) {
|
|
608
612
|
// For Windows
|
|
609
613
|
this.vt.write('\x1Bc');
|
|
610
614
|
//this.ptyProcess.write('cls\n');
|
|
@@ -749,7 +753,7 @@ class Shell {
|
|
|
749
753
|
// if params.message is empty, filter out
|
|
750
754
|
//let delimiter = " && "
|
|
751
755
|
let delimiter
|
|
752
|
-
if (this.
|
|
756
|
+
if (this.isCmdShell()) {
|
|
753
757
|
if (params.chain) {
|
|
754
758
|
if (params.chain === "&") {
|
|
755
759
|
delimiter = " && "; // stop if one command in the chain fails
|
|
@@ -887,7 +891,7 @@ class Shell {
|
|
|
887
891
|
// 2. conda_activation
|
|
888
892
|
|
|
889
893
|
let timeout
|
|
890
|
-
if (this.
|
|
894
|
+
if (this.isCmdShell()) {
|
|
891
895
|
timeout = 'C:\\Windows\\System32\\timeout /t 1 > nul'
|
|
892
896
|
} else {
|
|
893
897
|
//timeout = "sleep '1'"
|
package/kernel/shells.js
CHANGED
|
@@ -17,6 +17,23 @@ class Shells {
|
|
|
17
17
|
this.bracketedPasteDetections = new Map()
|
|
18
18
|
|
|
19
19
|
}
|
|
20
|
+
resolveShellExecutable(shellName) {
|
|
21
|
+
if (typeof shellName !== "string") {
|
|
22
|
+
return shellName
|
|
23
|
+
}
|
|
24
|
+
const trimmed = shellName.trim()
|
|
25
|
+
if (!trimmed || path.isAbsolute(trimmed)) {
|
|
26
|
+
return trimmed
|
|
27
|
+
}
|
|
28
|
+
if (trimmed.includes("/") || trimmed.includes("\\")) {
|
|
29
|
+
return trimmed
|
|
30
|
+
}
|
|
31
|
+
const resolved = this.kernel.which(trimmed)
|
|
32
|
+
if (resolved) {
|
|
33
|
+
return resolved
|
|
34
|
+
}
|
|
35
|
+
return trimmed
|
|
36
|
+
}
|
|
20
37
|
/*
|
|
21
38
|
params := {
|
|
22
39
|
"id": <shell id>,
|
|
@@ -237,6 +254,10 @@ class Shells {
|
|
|
237
254
|
)
|
|
238
255
|
}
|
|
239
256
|
|
|
257
|
+
if (params.shell) {
|
|
258
|
+
// Resolve bare command names before probing/launching so Windows can find bundled bash reliably.
|
|
259
|
+
params.shell = this.resolveShellExecutable(params.shell)
|
|
260
|
+
}
|
|
240
261
|
const plannedShell = params.shell || (this.kernel.platform === 'win32' ? 'cmd.exe' : 'bash')
|
|
241
262
|
await this.ensureBracketedPasteSupport(plannedShell)
|
|
242
263
|
let sh = new Shell(this.kernel)
|