pinokiod 3.315.0 → 3.316.0

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.
Files changed (2) hide show
  1. package/kernel/util.js +27 -23
  2. package/package.json +1 -1
package/kernel/util.js CHANGED
@@ -322,36 +322,40 @@ const exists= (abspath) => {
322
322
  return new Promise(r=>fs.access(abspath, fs.constants.F_OK, e => r(!e)))
323
323
  }
324
324
  const log = async (filepath, str, session) => {
325
- if (str && str.trim().length > 0) {
326
- let e = await exists(filepath)
327
- if (!e) {
328
- await fs.promises.mkdir(filepath, { recursive: true })
329
- }
325
+ try {
326
+ if (str && str.trim().length > 0) {
327
+ let e = await exists(filepath)
328
+ if (!e) {
329
+ await fs.promises.mkdir(filepath, { recursive: true })
330
+ }
330
331
 
331
- let output = '';
332
- for (let line of str.split('\n')) {
333
- line = line.split('\r').pop(); // handle overwriting lines
334
- output += line + '\n';
335
- }
332
+ let output = '';
333
+ for (let line of str.split('\n')) {
334
+ line = line.split('\r').pop(); // handle overwriting lines
335
+ output += line + '\n';
336
+ }
336
337
 
337
- const pattern = [
338
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
339
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-Za-z=><~]))'
340
- ].join('|');
341
- const regex = new RegExp(pattern, 'gi')
342
- let stripped = str.replaceAll(regex, '');
338
+ const pattern = [
339
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
340
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-Za-z=><~]))'
341
+ ].join('|');
342
+ const regex = new RegExp(pattern, 'gi')
343
+ let stripped = str.replaceAll(regex, '');
343
344
 
344
- // write to session
345
- let logpath = path.resolve(filepath, session)
346
- await fs.promises.writeFile(logpath, stripped)
345
+ // write to session
346
+ let logpath = path.resolve(filepath, session)
347
+ await fs.promises.writeFile(logpath, stripped)
347
348
 
348
- // create latest from last 10 sessions
349
+ // create latest from last 10 sessions
349
350
 
350
- let dirpath = path.dirname(filepath)
351
+ let dirpath = path.dirname(filepath)
351
352
 
352
353
 
353
- let latest_logpath = path.resolve(filepath, "latest")
354
- await fs.promises.writeFile(latest_logpath, stripped)
354
+ let latest_logpath = path.resolve(filepath, "latest")
355
+ await fs.promises.writeFile(latest_logpath, stripped)
356
+ }
357
+ } catch (e) {
358
+ console.log(">> Util.log error", { filepath, str, session}, e)
355
359
  }
356
360
  }
357
361
  const run = (cmd, cwd, kernel) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.315.0",
3
+ "version": "3.316.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {