pinokiod 2.15.39 → 2.15.41

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,37 @@ 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 mode = "view"
68
+ if (options && options.mode) {
69
+ mode = options.mode
70
+ }
71
+ if (mode === "view") {
72
+ switch (platform) {
73
+ case 'darwin':
74
+ command = `open -R "${dirPath}"`;
75
+ break;
76
+ case 'win32':
77
+ command = `explorer /select,"${dirPath}" & timeout /t 1 >nul`;
78
+ break;
79
+ default:
80
+ command = `xdg-open "${dirPath}"`;
81
+ break;
82
+ }
83
+ } else if (mode === "open") {
84
+ switch (platform) {
85
+ case 'darwin':
86
+ command = `open "${dirPath}"`;
87
+ break;
88
+ case 'win32':
89
+ command = `explorer "${dirPath}"`;
90
+ break;
91
+ default:
92
+ command = `xdg-open "${dirPath}"`;
93
+ break;
94
+ }
77
95
  }
78
96
  child_process.exec(command)
79
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "2.15.39",
3
+ "version": "2.15.41",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -1761,6 +1761,7 @@ class Server {
1761
1761
  }
1762
1762
 
1763
1763
  async syncConfig() {
1764
+
1764
1765
  // 1. THEME
1765
1766
  this.theme = this.kernel.store.get("theme") || "light"
1766
1767
  if (this.theme === "dark") {
@@ -2018,6 +2019,22 @@ class Server {
2018
2019
  await fs.promises.writeFile(path.resolve(this.homedir, "ENVIRONMENT"), str)
2019
2020
  }
2020
2021
 
2022
+ // custom theme
2023
+ console.log(this.kernel.path('web'))
2024
+ let exists = await fse.pathExists(this.kernel.path("web"))
2025
+ console.log("Exists", exists)
2026
+ if (exists) {
2027
+ let config_exists = await fse.pathExists(this.kernel.path("web/config.json"))
2028
+ if (config_exists) {
2029
+ let config = (await this.kernel.loader.load(this.kernel.path("web/config.json"))).resolved
2030
+ if (config) {
2031
+ if (config.color) this.colors.color = config.color
2032
+ if (config.symbolColor) this.colors.symbolColor = config.symbolColor
2033
+ }
2034
+ }
2035
+ }
2036
+
2037
+
2021
2038
  // let env = await Environment.get(this.kernel.homedir)
2022
2039
  // if (env && env.PINOKIO_PORT) {
2023
2040
  // this.port = env.PINOKIO_PORT
@@ -2234,7 +2251,7 @@ class Server {
2234
2251
  }))
2235
2252
 
2236
2253
  this.app.post("/openfs", ex(async (req, res) => {
2237
- Util.openfs(req.body.path)
2254
+ Util.openfs(req.body.path, req.body.mode)
2238
2255
  res.json({ success: true })
2239
2256
  }))
2240
2257
  this.app.get("/proxy", ex(async (req, res) => {
@@ -2650,10 +2667,21 @@ class Server {
2650
2667
  if (req.query && 'fs' in req.query) {
2651
2668
  // open in file system
2652
2669
  let full_filepath = this.kernel.path("api", ...pathComponents)
2653
- Util.openfs(full_filepath)
2654
- res.render("fs", {
2655
- path: full_filepath
2656
- })
2670
+ if (req.query.fs) {
2671
+ if (req.query.fs === 'open') {
2672
+ // open
2673
+ Util.openfs(full_filepath, { mode: "open" })
2674
+ } else if (req.query.fs === 'view') {
2675
+ // view
2676
+ Util.openfs(full_filepath, { mode: "view" })
2677
+ } else {
2678
+ // view
2679
+ Util.openfs(full_filepath, { mode: "view" })
2680
+ }
2681
+ res.render("fs", {
2682
+ path: full_filepath
2683
+ })
2684
+ }
2657
2685
  } else {
2658
2686
  try {
2659
2687
  await this.render(req, res, pathComponents)