Skip to content

Commit

Permalink
fix: prevent parsing wrappers and argument options as files to be ope…
Browse files Browse the repository at this point in the history
…ned by sabaki

Improve command-line argument options parse with minimist.

Refs: SabakiHQ#954
  • Loading branch information
esteban committed Jan 24, 2025
1 parent 2dd5882 commit 906d5fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"node_modules/@sabaki/i18n/**/*",
"node_modules/dolm/**/*",
"node_modules/{iconv-lite,safer-buffer}/**/*",
"node_modules/pikaday/css/*"
"node_modules/pikaday/css/*",
"node_modules/minimist"
]
},
"prettier": {
Expand Down Expand Up @@ -102,6 +103,7 @@
"fix-path": "<4.0.0",
"iconv-lite": "^0.5.1",
"jschardet": "^3.0.0",
"minimist": "^1.2.6",
"natsort": "^2.0.2",
"pikaday": "^1.8.0",
"preact": "^10.4.0",
Expand Down
12 changes: 7 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const {resolve} = require('path')
const i18n = require('./i18n')
const setting = require('./setting')
const updater = require('./updater')
const parseArgs = require('minimist')
const argv = parseArgs(process.argv, {boolean: true})
require('@electron/remote/main').initialize()

let windows = []
Expand Down Expand Up @@ -235,11 +237,11 @@ async function main() {

await app.whenReady()

if (!openfile && process.argv.length >= 2) {
if (!['electron.exe', 'electron'].some(x => process.argv[0].endsWith(x))) {
openfile = process.argv[1]
} else if (process.argv.length >= 3) {
openfile = process.argv[2]
if (!openfile) {
if (argv._[0].endsWith('sabaki')) {
openfile = argv._[1]
} else {
openfile = argv._[2]
}
}

Expand Down

0 comments on commit 906d5fb

Please sign in to comment.