pinokiod 2.1.13 → 2.1.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/kernel/bin/registry.js +1 -4
- package/kernel/environment.js +36 -18
- package/package.json +1 -1
package/kernel/bin/registry.js
CHANGED
|
@@ -20,19 +20,16 @@ class Registry {
|
|
|
20
20
|
if (chunks.length === 3) {
|
|
21
21
|
if (Number(chunks[2]) === 1) {
|
|
22
22
|
this._installed = true
|
|
23
|
-
return true
|
|
24
23
|
} else {
|
|
25
24
|
this._installed = false
|
|
26
|
-
return false
|
|
27
25
|
}
|
|
28
26
|
} else {
|
|
29
27
|
this._installed = false
|
|
30
|
-
return false
|
|
31
28
|
}
|
|
32
29
|
} else {
|
|
33
30
|
this._installed = false
|
|
34
|
-
return false
|
|
35
31
|
}
|
|
32
|
+
return this._installed
|
|
36
33
|
}
|
|
37
34
|
async install(req, ondata) {
|
|
38
35
|
// 1. Set registry to allow long paths
|
package/kernel/environment.js
CHANGED
|
@@ -293,6 +293,8 @@ const ENV = async (type, homedir) => {
|
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
console.log({ filtered_envs, irrelevant_keys })
|
|
297
|
+
|
|
296
298
|
// let filtered_envs = envs.filter((e) => {
|
|
297
299
|
// return e.type.includes(type)
|
|
298
300
|
// })
|
|
@@ -315,9 +317,9 @@ const ENV = async (type, homedir) => {
|
|
|
315
317
|
|
|
316
318
|
// if app environment,
|
|
317
319
|
// if e.key exists on system env, use that
|
|
318
|
-
// if e.key does NOT exist on system env,
|
|
320
|
+
// if e.key does NOT exist on system env, use from the hardcoded default option
|
|
319
321
|
if (type === 'app') {
|
|
320
|
-
system_env = await
|
|
322
|
+
system_env = await get_raw(homedir)
|
|
321
323
|
if (e.key in system_env) {
|
|
322
324
|
console.log(`original ${e.key}=${val}`)
|
|
323
325
|
val = system_env[e.key]
|
|
@@ -331,25 +333,25 @@ const ENV = async (type, homedir) => {
|
|
|
331
333
|
lines.push(comment+kv)
|
|
332
334
|
}
|
|
333
335
|
|
|
334
|
-
// In case of type: app, inherit any other custom ENVIRONMENT variable not yet included
|
|
335
|
-
console.log({ irrelevant_keys })
|
|
336
|
-
if (type === "app" && system_env) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
336
|
+
// In case of type: app, inherit any other custom ENVIRONMENT variable not yet included
|
|
337
|
+
console.log({ irrelevant_keys })
|
|
338
|
+
if (type === "app" && system_env) {
|
|
339
|
+
for(let key in system_env) {
|
|
340
|
+
if (!keys.has(key)) {
|
|
341
|
+
// the key has not been processed, need to add to the lines
|
|
342
|
+
if (irrelevant_keys.includes(key)) {
|
|
343
|
+
// if the key was explicitly stated to be not included, skip
|
|
344
|
+
console.log("irrelevant key", key)
|
|
345
|
+
} else {
|
|
346
|
+
console.log("relevant key", key)
|
|
347
|
+
let val = system_env[key]
|
|
348
|
+
let kv = `${key}=${val}`
|
|
349
|
+
lines.push(kv)
|
|
350
|
+
console.log(`inherited custom environment key from system_env: ${kv}`)
|
|
351
|
+
}
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
354
|
}
|
|
352
|
-
}
|
|
353
355
|
|
|
354
356
|
return lines.join("\n")
|
|
355
357
|
}
|
|
@@ -381,6 +383,10 @@ const get2 = async (filepath, kernel) => {
|
|
|
381
383
|
let current_env = Object.assign({}, process.env, default_env, api_env)
|
|
382
384
|
return current_env
|
|
383
385
|
}
|
|
386
|
+
|
|
387
|
+
// return env object
|
|
388
|
+
// 1. if the value starts with ./ => convert to absolute path
|
|
389
|
+
// 2. if the value is empty => don't return the kv pair for that value
|
|
384
390
|
const get = async (homedir) => {
|
|
385
391
|
const env_path = path.resolve(homedir, "ENVIRONMENT")
|
|
386
392
|
const current_env = await Util.parse_env(env_path)
|
|
@@ -396,4 +402,16 @@ const get = async (homedir) => {
|
|
|
396
402
|
}
|
|
397
403
|
return current_env
|
|
398
404
|
}
|
|
405
|
+
|
|
406
|
+
const get_raw = async (homedir) => {
|
|
407
|
+
const env_path = path.resolve(homedir, "ENVIRONMENT")
|
|
408
|
+
const current_env = await Util.parse_env(env_path)
|
|
409
|
+
for(let key in current_env) {
|
|
410
|
+
let val = current_env[key]
|
|
411
|
+
if (val.trim() === "") {
|
|
412
|
+
delete current_env[key]
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return current_env
|
|
416
|
+
}
|
|
399
417
|
module.exports = { ENV, get, get2, init_folders }
|