fix(windows): fix starting under some path'es
This commit is contained in:
7
package-lock.json
generated
7
package-lock.json
generated
@ -6163,6 +6163,11 @@
|
|||||||
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=",
|
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"detect-onebyte-encoding": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/detect-onebyte-encoding/-/detect-onebyte-encoding-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-JmhHYhr7w6GlklJTzws0QCfsX71s57q1zkQHQ8sOJmMdtZ5W+5Mwsw8wKGicfR79cZxMXO+0sqQagwRTxRFdIw=="
|
||||||
|
},
|
||||||
"dev-null": {
|
"dev-null": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/dev-null/-/dev-null-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/dev-null/-/dev-null-0.1.1.tgz",
|
||||||
@ -6783,7 +6788,7 @@
|
|||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
@ -117,6 +117,7 @@
|
|||||||
"cheerio": "^1.0.0-rc.2",
|
"cheerio": "^1.0.0-rc.2",
|
||||||
"compare-versions": "^3.1.0",
|
"compare-versions": "^3.1.0",
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
|
"detect-onebyte-encoding": "^1.0.2",
|
||||||
"electron-context-menu": "^0.9.1",
|
"electron-context-menu": "^0.9.1",
|
||||||
"electron-log": "^2.2.14",
|
"electron-log": "^2.2.14",
|
||||||
"electron-updater": "^2.21.10",
|
"electron-updater": "^2.21.10",
|
||||||
|
@ -12,6 +12,7 @@ const findFiles = require('./findFiles')
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const isRunning = require('is-running')
|
const isRunning = require('is-running')
|
||||||
const portCheck = require('./portCheck')
|
const portCheck = require('./portCheck')
|
||||||
|
const detectOnebyteEncoding = require('detect-onebyte-encoding')
|
||||||
|
|
||||||
const findGoodPort = async (port, host) => {
|
const findGoodPort = async (port, host) => {
|
||||||
while (!(await portCheck(port, host))) {
|
while (!(await portCheck(port, host))) {
|
||||||
@ -150,8 +151,18 @@ const writeSphinxConfig = async (path, dbPath) => {
|
|||||||
isInitDb = true
|
isInitDb = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fix db path under windows platform (one-byte path)
|
||||||
if(/^win/.test(process.platform))
|
if(/^win/.test(process.platform))
|
||||||
config = iconv.encode(config, 'win1251')
|
{
|
||||||
|
let encoding = detectOnebyteEncoding(dbPath)
|
||||||
|
let encoding2 = detectOnebyteEncoding(path)
|
||||||
|
if(encoding != encoding2)
|
||||||
|
{
|
||||||
|
encoding = detectOnebyteEncoding(config)
|
||||||
|
}
|
||||||
|
config = iconv.encode(config, encoding)
|
||||||
|
logT('sphinx', 'config encoded to', encoding)
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFileSync(`${path}/sphinx.conf`, config)
|
fs.writeFileSync(`${path}/sphinx.conf`, config)
|
||||||
logT('sphinx', `writed sphinx config to ${path}`)
|
logT('sphinx', `writed sphinx config to ${path}`)
|
||||||
|
Reference in New Issue
Block a user