Skip to content

Commit

Permalink
fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozzz committed Jul 20, 2018
1 parent 77a095c commit 9650923
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ async function main() {
let argv;
// case: Windows
if (os.platform() === 'win32') {
try {
// case: run by 'node index.js'
argv = require('./' + 'config.txt');
} catch(e) {
// case: run by exe
let path = process.execPath;
path = `${path.slice(0, path.lastIndexOf('\\'))}/config.txt`;
path = `${path.slice(0, path.lastIndexOf('\\'))}\\config.txt`;
argv = require(path);
}
} else {
try {
// case: Linux & MacOS terminal run, dynamic to avoid packaing
// case: Linux & MacOS terminal run, dynamic to avoid packaging
argv = require('./' + 'config.txt');
} catch(e) {
// case: MacOS double click
Expand Down

0 comments on commit 9650923

Please sign in to comment.