atom / node-spellchecker

SpellChecker Node Module
http://atom.github.io/node-spellchecker
MIT License
300 stars 108 forks source link

When using spellchecker with Electron v3, get deprecation warning #105

Closed scottnonnenberg-signal closed 5 years ago

scottnonnenberg-signal commented 6 years ago

When using spellchecker with Electron v3.0.9, you get this warning to the console.

fs.js:958 (electron) The 'lstatSyncNoException' function has been deprecated and marked for removal.
  fs.statSyncNoException @ fs.js:958
  fs.statSyncNoException @ ELECTRON_ASAR.js:319
  getDictionaryPath @ /Users/scott/dev/desktop/node_modules/spellchecker/lib/spellchecker.js:87
  ensureDefaultSpellCheck @ /Users/scott/dev/desktop/node_modules/spellchecker/lib/spellchecker.js:32
  isMisspelled @ /Users/scott/dev/desktop/node_modules/spellchecker/lib/spellchecker.js:41
  isMisspelled @ /Users/scott/dev/desktop/js/spell_check.js:103
  spellCheck @ /Users/scott/dev/desktop/js/spell_check.js:100

This is the problematic code:

var getDictionaryPath = function() {
  var dict = path.join(__dirname, '..', 'vendor', 'hunspell_dictionaries');
  try {
    // HACK: Special case being in an asar archive
    var unpacked = dict.replace('.asar' + path.sep, '.asar.unpacked' + path.sep);
    if (require('fs').statSyncNoException(unpacked)) {
      dict = unpacked;
    }
  } catch (error) {
  }
  return dict;
}