ELECTRON-1170 - Remove ncp module

This commit is contained in:
Kiran Niranjan 2019-04-26 15:26:05 +05:30
parent f548a93a58
commit 6f07376e9f
3 changed files with 17 additions and 41 deletions

View File

@ -7,8 +7,6 @@ const crashReporter = electron.crashReporter;
const nodeURL = require('url');
const shellPath = require('shell-path');
const urlParser = require('url');
const { ncp } = require('ncp');
const path = require('path');
const nodePath = require('path');
require('electron-dl')();
@ -31,8 +29,8 @@ const getCmdLineArg = require('./utils/getCmdLineArg.js');
//setting the env path child_process issue https://github.com/electron/electron/issues/7688
shellPath()
.then((sPath) => {
process.env.PATH = sPath
.then((path) => {
process.env.PATH = path
})
.catch(() => {
process.env.PATH = [
@ -351,7 +349,6 @@ function setupFirstTimeLaunch(resolve, reject, shouldUpdateUserConfig) {
log.send(logLevels.INFO, 'setting first time launch config');
getConfigField('launchOnStartup')
.then(setStartup)
.then(copyDictionaries)
.then(() => {
if (shouldUpdateUserConfig) {
log.send(logLevels.INFO, `Resetting user config data? ${shouldUpdateUserConfig}`);
@ -362,37 +359,6 @@ function setupFirstTimeLaunch(resolve, reject, shouldUpdateUserConfig) {
.catch(reject);
}
/**
* Copies all the dictionaries files required
* for spellchecker module
* @return {Promise<any>}
*/
function copyDictionaries() {
return new Promise(resolve => {
if (isMac) {
resolve();
return;
}
const dictionariesDirName = 'dictionaries';
let dictionaryPath;
if (isDevEnv) {
dictionaryPath = path.join(app.getAppPath(), dictionariesDirName);
} else {
let execPath = path.dirname(app.getPath('exe'));
dictionaryPath = path.join(execPath, isMac ? '..' : '', dictionariesDirName);
}
const userDictionaries = path.join(app.getPath('userData'), dictionariesDirName);
ncp(dictionaryPath, userDictionaries, (error) => {
if (error) {
log.send(logLevels.ERROR, `unable to copy dictionaries ${error}`);
}
return resolve();
});
})
}
/**
* Sets Symphony on startup
* @param lStartup

View File

@ -1,6 +1,7 @@
const { app, MenuItem } = require('electron');
const { isMac } = require('./../utils/misc');
const { SpellCheckHandler } = require('electron-spellchecker');
const path = require('path');
const { isMac, isDevEnv } = require('./../utils/misc');
const { SpellCheckHandler, DictionarySync } = require('electron-spellchecker');
const stringFormat = require('./../utils/stringFormat');
class SpellCheckHelper {
@ -9,7 +10,16 @@ class SpellCheckHelper {
* A constructor to create an instance of the spell checker
*/
constructor() {
this.spellCheckHandler = new SpellCheckHandler();
const dictionariesDirName = 'dictionaries';
let dictionaryPath;
if (isDevEnv) {
dictionaryPath = path.join(app.getAppPath(), dictionariesDirName);
} else {
let execPath = path.dirname(app.getPath('exe'));
dictionaryPath = path.join(execPath, isMac ? '..' : '', dictionariesDirName);
}
this.dictionarySync = new DictionarySync(dictionaryPath);
this.spellCheckHandler = new SpellCheckHandler(this.dictionarySync);
}
/**
@ -109,4 +119,4 @@ class SpellCheckHelper {
module.exports = {
SpellCheckHelper: SpellCheckHelper
};
};

View File

@ -101,6 +101,7 @@
"glob": "7.1.3",
"jest": "23.6.0",
"jest-html-reporter": "2.4.2",
"ncp": "2.0.0",
"robotjs": "0.5.1",
"selenium-webdriver": "3.6.0",
"wdio-selenium-standalone-service": "0.0.12"
@ -122,7 +123,6 @@
"lodash.isequal": "4.5.0",
"lodash.omit": "4.5.0",
"lodash.pick": "4.4.0",
"ncp": "2.0.0",
"node-osascript": "2.1.0",
"ref": "1.3.5",
"shell-path": "2.1.0",