pinokiod 2.15.39 → 2.15.40

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.
@@ -75,12 +75,17 @@ class FS {
75
75
  /*
76
76
  params := {
77
77
  path: <filepath>,
78
+ mode: "view(default)|open"
78
79
  }
79
80
  open finder/file explorer at path
80
81
  */
81
82
  let dirPath = path.resolve(req.cwd, req.params.path)
82
83
  ondata({ raw: `\r\nopening path: ${dirPath}\r\n` })
83
- Util.openfs(dirPath)
84
+ if (req.params.mode) {
85
+ Util.openfs(dirPath, req.params.mode)
86
+ } else {
87
+ Util.openfs(dirPath)
88
+ }
84
89
  }
85
90
 
86
91
  async link(req, ondata, kernel) {
package/kernel/util.js CHANGED
@@ -61,19 +61,38 @@ const parse_env = async (filename) => {
61
61
  return {}
62
62
  }
63
63
  }
64
- const openfs = (dirPath) => {
64
+ const openfs = (dirPath, options) => {
65
65
  let command = '';
66
66
  const platform = os.platform()
67
- switch (platform) {
68
- case 'darwin':
69
- command = `open -R "${dirPath}"`;
70
- break;
71
- case 'win32':
72
- command = `explorer /select,"${dirPath}" & timeout /t 1 >nul`;
73
- break;
74
- default:
75
- command = `xdg-open "${dirPath}"`;
76
- break;
67
+ let type = (options && options.
68
+ let mode = "view"
69
+ if (options && options.mode) {
70
+ mode = options.mode
71
+ }
72
+ if (mode === "view") {
73
+ switch (platform) {
74
+ case 'darwin':
75
+ command = `open -R "${dirPath}"`;
76
+ break;
77
+ case 'win32':
78
+ command = `explorer /select,"${dirPath}" & timeout /t 1 >nul`;
79
+ break;
80
+ default:
81
+ command = `xdg-open "${dirPath}"`;
82
+ break;
83
+ }
84
+ } else if (mode === "open") {
85
+ switch (platform) {
86
+ case 'darwin':
87
+ command = `open "${dirPath}"`;
88
+ break;
89
+ case 'win32':
90
+ command = `explorer "${dirPath}"`;
91
+ break;
92
+ default:
93
+ command = `xdg-open "${dirPath}"`;
94
+ break;
95
+ }
77
96
  }
78
97
  child_process.exec(command)
79
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "2.15.39",
3
+ "version": "2.15.40",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -2234,7 +2234,7 @@ class Server {
2234
2234
  }))
2235
2235
 
2236
2236
  this.app.post("/openfs", ex(async (req, res) => {
2237
- Util.openfs(req.body.path)
2237
+ Util.openfs(req.body.path, req.body.mode)
2238
2238
  res.json({ success: true })
2239
2239
  }))
2240
2240
  this.app.get("/proxy", ex(async (req, res) => {
@@ -2650,10 +2650,21 @@ class Server {
2650
2650
  if (req.query && 'fs' in req.query) {
2651
2651
  // open in file system
2652
2652
  let full_filepath = this.kernel.path("api", ...pathComponents)
2653
- Util.openfs(full_filepath)
2654
- res.render("fs", {
2655
- path: full_filepath
2656
- })
2653
+ if (req.query.fs) {
2654
+ if (req.query.fs === 'open') {
2655
+ // open
2656
+ Util.openfs(full_filepath, { mode: "open" })
2657
+ } else if (req.query.fs === 'view') {
2658
+ // view
2659
+ Util.openfs(full_filepath, { mode: "view" })
2660
+ } else {
2661
+ // view
2662
+ Util.openfs(full_filepath, { mode: "view" })
2663
+ }
2664
+ res.render("fs", {
2665
+ path: full_filepath
2666
+ })
2667
+ }
2657
2668
  } else {
2658
2669
  try {
2659
2670
  await this.render(req, res, pathComponents)