From d8b625f2f42d5cc6c4a9390216ac1e5037886e44 Mon Sep 17 00:00:00 2001 From: Jason Dent Date: Sun, 8 Nov 2020 20:22:47 +0100 Subject: [PATCH] fix: do not include Configstore if not necessary (#270) * fix: do not include Configstore if not necessary * ci: make sure line endings are preserved --- .gitattributes | 3 ++ .../generators/app/templates/package.json | 7 ++-- packages/ada/index.js | 4 +-- packages/ada/link.js | 2 +- packages/ada/package.json | 4 +++ packages/ada/unlink.js | 2 +- packages/ada/util.js | 34 +++++++++---------- packages/aws/index.js | 4 +-- packages/aws/link.js | 2 +- packages/aws/package.json | 4 +++ packages/aws/unlink.js | 2 +- packages/aws/util.js | 34 +++++++++---------- packages/bash/index.js | 4 +-- packages/bash/link.js | 2 +- packages/bash/package.json | 4 +++ packages/bash/unlink.js | 2 +- packages/bash/util.js | 34 +++++++++---------- packages/bg_BG/index.js | 4 +-- packages/bg_BG/link.js | 2 +- packages/bg_BG/package.json | 4 +++ packages/bg_BG/unlink.js | 2 +- packages/bg_BG/util.js | 34 +++++++++---------- packages/ca/index.js | 4 +-- packages/ca/link.js | 2 +- packages/ca/package.json | 4 +++ packages/ca/unlink.js | 2 +- packages/ca/util.js | 34 +++++++++---------- packages/city-names-finland/index.js | 4 +-- packages/city-names-finland/link.js | 2 +- packages/city-names-finland/package.json | 4 +++ packages/city-names-finland/unlink.js | 2 +- packages/city-names-finland/util.js | 34 +++++++++---------- packages/companies/index.js | 4 +-- packages/companies/link.js | 2 +- packages/companies/package.json | 4 +++ packages/companies/unlink.js | 2 +- packages/companies/util.js | 34 +++++++++---------- packages/cpp/index.js | 4 +-- packages/cpp/link.js | 2 +- packages/cpp/package.json | 4 +++ packages/cpp/unlink.js | 2 +- packages/cpp/util.js | 34 +++++++++---------- packages/cryptocurrencies/index.js | 4 +-- packages/cryptocurrencies/link.js | 2 +- packages/cryptocurrencies/package.json | 4 +++ packages/cryptocurrencies/unlink.js | 2 +- packages/cryptocurrencies/util.js | 34 +++++++++---------- packages/cs_CZ/index.js | 4 +-- packages/cs_CZ/link.js | 2 +- packages/cs_CZ/package.json | 4 +++ packages/cs_CZ/unlink.js | 2 +- packages/cs_CZ/util.js | 34 +++++++++---------- packages/csharp/index.js | 4 +-- packages/csharp/link.js | 2 +- packages/csharp/package.json | 4 +++ packages/csharp/unlink.js | 2 +- packages/csharp/util.js | 34 +++++++++---------- packages/css/index.js | 4 +-- packages/css/link.js | 2 +- packages/css/package.json | 4 +++ packages/css/unlink.js | 2 +- packages/css/util.js | 34 +++++++++---------- packages/da_DK/index.js | 4 +-- packages/da_DK/link.js | 2 +- packages/da_DK/package.json | 4 +++ packages/da_DK/unlink.js | 2 +- packages/da_DK/util.js | 34 +++++++++---------- packages/de_DE/index.js | 4 +-- packages/de_DE/link.js | 2 +- packages/de_DE/package.json | 4 +++ packages/de_DE/unlink.js | 2 +- packages/de_DE/util.js | 34 +++++++++---------- packages/django/index.js | 4 +-- packages/django/link.js | 2 +- packages/django/package.json | 4 +++ packages/django/unlink.js | 2 +- packages/django/util.js | 34 +++++++++---------- packages/dotnet/index.js | 4 +-- packages/dotnet/link.js | 2 +- packages/dotnet/package.json | 4 +++ packages/dotnet/unlink.js | 2 +- packages/dotnet/util.js | 34 +++++++++---------- packages/el/package.json | 4 +++ packages/elixir/index.js | 4 +-- packages/elixir/link.js | 2 +- packages/elixir/package.json | 4 +++ packages/elixir/unlink.js | 2 +- packages/elixir/util.js | 34 +++++++++---------- packages/en_GB/index.js | 4 +-- packages/en_GB/link.js | 2 +- packages/en_GB/package.json | 4 +++ packages/en_GB/unlink.js | 2 +- packages/en_GB/util.js | 34 +++++++++---------- packages/en_US/index.js | 4 +-- packages/en_US/link.js | 2 +- packages/en_US/package.json | 4 +++ packages/en_US/unlink.js | 2 +- packages/en_US/util.js | 34 +++++++++---------- packages/eo/index.js | 4 +-- packages/eo/link.js | 2 +- packages/eo/package.json | 4 +++ packages/eo/unlink.js | 2 +- packages/eo/util.js | 34 +++++++++---------- packages/es_ES/index.js | 4 +-- packages/es_ES/link.js | 2 +- packages/es_ES/package.json | 4 +++ packages/es_ES/unlink.js | 2 +- packages/es_ES/util.js | 34 +++++++++---------- packages/fa_IR/index.js | 4 +-- packages/fa_IR/link.js | 2 +- packages/fa_IR/package.json | 4 +++ packages/fa_IR/unlink.js | 2 +- packages/fa_IR/util.js | 34 +++++++++---------- packages/filetypes/index.js | 4 +-- packages/filetypes/link.js | 2 +- packages/filetypes/package.json | 4 +++ packages/filetypes/unlink.js | 2 +- packages/filetypes/util.js | 34 +++++++++---------- packages/fonts/index.js | 4 +-- packages/fonts/link.js | 2 +- packages/fonts/package.json | 4 +++ packages/fonts/unlink.js | 2 +- packages/fonts/util.js | 34 +++++++++---------- packages/fr_FR/index.js | 4 +-- packages/fr_FR/link.js | 2 +- packages/fr_FR/package.json | 4 +++ packages/fr_FR/unlink.js | 2 +- packages/fr_FR/util.js | 34 +++++++++---------- packages/fr_FR_90/index.js | 4 +-- packages/fr_FR_90/link.js | 2 +- packages/fr_FR_90/package.json | 4 +++ packages/fr_FR_90/unlink.js | 2 +- packages/fr_FR_90/util.js | 34 +++++++++---------- packages/fullstack/index.js | 4 +-- packages/fullstack/link.js | 2 +- packages/fullstack/package.json | 4 +++ packages/fullstack/unlink.js | 2 +- packages/fullstack/util.js | 34 +++++++++---------- packages/golang/index.js | 4 +-- packages/golang/link.js | 2 +- packages/golang/package.json | 4 +++ packages/golang/unlink.js | 2 +- packages/golang/util.js | 34 +++++++++---------- packages/haskell/index.js | 4 +-- packages/haskell/link.js | 2 +- packages/haskell/package.json | 4 +++ packages/haskell/unlink.js | 2 +- packages/haskell/util.js | 34 +++++++++---------- packages/he/index.js | 4 +-- packages/he/link.js | 2 +- packages/he/package.json | 4 +++ packages/he/unlink.js | 2 +- packages/he/util.js | 34 +++++++++---------- packages/hr_HR/index.js | 4 +-- packages/hr_HR/link.js | 2 +- packages/hr_HR/package.json | 4 +++ packages/hr_HR/unlink.js | 2 +- packages/hr_HR/util.js | 34 +++++++++---------- packages/html-symbol-entities/index.js | 4 +-- packages/html-symbol-entities/link.js | 2 +- packages/html-symbol-entities/package.json | 4 +++ packages/html-symbol-entities/unlink.js | 2 +- packages/html-symbol-entities/util.js | 34 +++++++++---------- packages/html/index.js | 4 +-- packages/html/link.js | 2 +- packages/html/package.json | 4 +++ packages/html/unlink.js | 2 +- packages/html/util.js | 34 +++++++++---------- packages/it_IT/index.js | 4 +-- packages/it_IT/link.js | 2 +- packages/it_IT/package.json | 4 +++ packages/it_IT/unlink.js | 2 +- packages/it_IT/util.js | 34 +++++++++---------- packages/java/index.js | 4 +-- packages/java/link.js | 2 +- packages/java/package.json | 4 +++ packages/java/unlink.js | 2 +- packages/java/util.js | 34 +++++++++---------- packages/latex/index.js | 4 +-- packages/latex/link.js | 2 +- packages/latex/package.json | 4 +++ packages/latex/unlink.js | 2 +- packages/latex/util.js | 34 +++++++++---------- packages/lorem-ipsum/index.js | 4 +-- packages/lorem-ipsum/link.js | 2 +- packages/lorem-ipsum/package.json | 4 +++ packages/lorem-ipsum/unlink.js | 2 +- packages/lorem-ipsum/util.js | 34 +++++++++---------- packages/lt_LT/index.js | 4 +-- packages/lt_LT/link.js | 2 +- packages/lt_LT/package.json | 4 +++ packages/lt_LT/unlink.js | 2 +- packages/lt_LT/util.js | 34 +++++++++---------- packages/lua/index.js | 4 +-- packages/lua/link.js | 2 +- packages/lua/package.json | 4 +++ packages/lua/unlink.js | 2 +- packages/lua/util.js | 34 +++++++++---------- packages/medicalterms/index.js | 4 +-- packages/medicalterms/link.js | 2 +- packages/medicalterms/package.json | 4 +++ packages/medicalterms/unlink.js | 2 +- packages/medicalterms/util.js | 34 +++++++++---------- packages/nl_NL/index.js | 4 +-- packages/nl_NL/link.js | 2 +- packages/nl_NL/package.json | 4 +++ packages/nl_NL/unlink.js | 2 +- packages/nl_NL/util.js | 34 +++++++++---------- packages/node/index.js | 4 +-- packages/node/link.js | 2 +- packages/node/package.json | 4 +++ packages/node/unlink.js | 2 +- packages/node/util.js | 34 +++++++++---------- packages/npm/index.js | 4 +-- packages/npm/link.js | 2 +- packages/npm/package.json | 4 +++ packages/npm/unlink.js | 2 +- packages/npm/util.js | 34 +++++++++---------- packages/php/index.js | 4 +-- packages/php/link.js | 2 +- packages/php/package.json | 4 +++ packages/php/unlink.js | 2 +- packages/php/util.js | 34 +++++++++---------- packages/pl_PL/index.js | 4 +-- packages/pl_PL/link.js | 2 +- packages/pl_PL/package.json | 4 +++ packages/pl_PL/unlink.js | 2 +- packages/pl_PL/util.js | 34 +++++++++---------- packages/powershell/index.js | 4 +-- packages/powershell/link.js | 2 +- packages/powershell/package.json | 4 +++ packages/powershell/unlink.js | 2 +- packages/powershell/util.js | 34 +++++++++---------- packages/pt_BR/index.js | 4 +-- packages/pt_BR/link.js | 2 +- packages/pt_BR/package.json | 4 +++ packages/pt_BR/unlink.js | 2 +- packages/pt_BR/util.js | 34 +++++++++---------- packages/pt_PT/index.js | 4 +-- packages/pt_PT/link.js | 2 +- packages/pt_PT/package.json | 4 +++ packages/pt_PT/unlink.js | 2 +- packages/pt_PT/util.js | 34 +++++++++---------- packages/python/index.js | 4 +-- packages/python/link.js | 2 +- packages/python/package.json | 4 +++ packages/python/unlink.js | 2 +- packages/python/util.js | 34 +++++++++---------- packages/ru_RU/index.js | 4 +-- packages/ru_RU/link.js | 2 +- packages/ru_RU/package.json | 4 +++ packages/ru_RU/unlink.js | 2 +- packages/ru_RU/util.js | 34 +++++++++---------- packages/ruby/index.js | 4 +-- packages/ruby/link.js | 2 +- packages/ruby/package.json | 4 +++ packages/ruby/unlink.js | 2 +- packages/ruby/util.js | 34 +++++++++---------- packages/russian/index.js | 4 +-- packages/russian/link.js | 2 +- packages/russian/package.json | 4 +++ packages/russian/unlink.js | 2 +- packages/russian/util.js | 34 +++++++++---------- packages/rust/index.js | 4 +-- packages/rust/link.js | 2 +- packages/rust/package.json | 4 +++ packages/rust/unlink.js | 2 +- packages/rust/util.js | 34 +++++++++---------- packages/scala/index.js | 4 +-- packages/scala/link.js | 2 +- packages/scala/package.json | 4 +++ packages/scala/unlink.js | 2 +- packages/scala/util.js | 34 +++++++++---------- packages/scientific_terms_US/index.js | 4 +-- packages/scientific_terms_US/link.js | 2 +- packages/scientific_terms_US/package.json | 4 +++ packages/scientific_terms_US/unlink.js | 2 +- packages/scientific_terms_US/util.js | 34 +++++++++---------- packages/software-terms/index.js | 4 +-- packages/software-terms/link.js | 2 +- packages/software-terms/package.json | 4 +++ packages/software-terms/unlink.js | 2 +- packages/software-terms/util.js | 34 +++++++++---------- packages/sv/index.js | 4 +-- packages/sv/link.js | 2 +- packages/sv/package.json | 4 +++ packages/sv/unlink.js | 2 +- packages/sv/util.js | 34 +++++++++---------- packages/tr_TR/index.js | 4 +-- packages/tr_TR/link.js | 2 +- packages/tr_TR/package.json | 4 +++ packages/tr_TR/unlink.js | 2 +- packages/tr_TR/util.js | 34 +++++++++---------- packages/typescript/index.js | 4 +-- packages/typescript/link.js | 2 +- packages/typescript/package.json | 4 +++ packages/typescript/unlink.js | 2 +- packages/typescript/util.js | 34 +++++++++---------- packages/uk_UA/index.js | 4 +-- packages/uk_UA/link.js | 2 +- packages/uk_UA/package.json | 4 +++ packages/uk_UA/unlink.js | 2 +- packages/uk_UA/util.js | 34 +++++++++---------- packages/vi_VN/index.js | 4 +-- packages/vi_VN/link.js | 2 +- packages/vi_VN/package.json | 4 +++ packages/vi_VN/unlink.js | 2 +- packages/vi_VN/util.js | 34 +++++++++---------- util/index.js | 4 +-- util/link.js | 2 +- util/unlink.js | 2 +- util/util.js | 34 +++++++++---------- 312 files changed, 1496 insertions(+), 1366 deletions(-) diff --git a/.gitattributes b/.gitattributes index 4cab1f4d267..dd864bb3c8e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ # Set the default behavior, in case people don't have core.autocrlf set. * text=auto +*.txt text eol=lf +*.ts text eol=lf +*.js text eol=lf diff --git a/generator-cspell-dicts/generators/app/templates/package.json b/generator-cspell-dicts/generators/app/templates/package.json index fbe64b2f1da..5509e8ab717 100644 --- a/generator-cspell-dicts/generators/app/templates/package.json +++ b/generator-cspell-dicts/generators/app/templates/package.json @@ -7,6 +7,10 @@ "<%= fullPackageName %>-link": "./link.js", "<%= fullPackageName %>-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 cspell-tools <%= command %> \"<%= srcFile %>\" -o .", "test": "head -n 100 \"<%= srcFile %>\" | cspell -v -c ./cspell-ext.json \"--local=<%= local %>\" \"--languageId=<%= languageId %>\" stdin", @@ -34,8 +38,7 @@ "url": "https://github.com/streetsidesoftware/cspell-dicts/issues" }, "homepage": "https://github.com/streetsidesoftware/cspell-dicts/blob/master/packages/<%= name %>#readme", - "devDependencies": { - }, + "devDependencies": {}, "dependencies": { "configstore": "^5.0.0" }, diff --git a/packages/ada/index.js b/packages/ada/index.js index 65943207811..caf7363cb96 100644 --- a/packages/ada/index.js +++ b/packages/ada/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/ada/link.js b/packages/ada/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/ada/link.js +++ b/packages/ada/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/ada/package.json b/packages/ada/package.json index a435bd5bd8c..3a6a845d6bd 100644 --- a/packages/ada/package.json +++ b/packages/ada/package.json @@ -6,6 +6,10 @@ "cspell-dict-ada-link": "./link.js", "cspell-dict-ada-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"ada.txt\" -o .", "test": "head -n 100 \"ada.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=ada stdin", diff --git a/packages/ada/unlink.js b/packages/ada/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/ada/unlink.js +++ b/packages/ada/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/ada/util.js b/packages/ada/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/ada/util.js +++ b/packages/ada/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/aws/index.js b/packages/aws/index.js index 65943207811..caf7363cb96 100644 --- a/packages/aws/index.js +++ b/packages/aws/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/aws/link.js b/packages/aws/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/aws/link.js +++ b/packages/aws/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/aws/package.json b/packages/aws/package.json index f093df20450..fde7482d31a 100644 --- a/packages/aws/package.json +++ b/packages/aws/package.json @@ -6,6 +6,10 @@ "cspell-dict-aws-link": "./link.js", "cspell-dict-aws-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"aws.txt\" -o .", "test": "head -n 100 \"aws.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=aws\" stdin", diff --git a/packages/aws/unlink.js b/packages/aws/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/aws/unlink.js +++ b/packages/aws/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/aws/util.js b/packages/aws/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/aws/util.js +++ b/packages/aws/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/bash/index.js b/packages/bash/index.js index 65943207811..caf7363cb96 100644 --- a/packages/bash/index.js +++ b/packages/bash/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/bash/link.js b/packages/bash/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/bash/link.js +++ b/packages/bash/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/bash/package.json b/packages/bash/package.json index 0547ffaa3fa..21fe29b5966 100644 --- a/packages/bash/package.json +++ b/packages/bash/package.json @@ -6,6 +6,10 @@ "cspell-dict-bash-link": "./link.js", "cspell-dict-bash-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"bash-words.txt\" -o .", "test": "head -n 100 \"bash-words.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=shellscript\" stdin", diff --git a/packages/bash/unlink.js b/packages/bash/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/bash/unlink.js +++ b/packages/bash/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/bash/util.js b/packages/bash/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/bash/util.js +++ b/packages/bash/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/bg_BG/index.js b/packages/bg_BG/index.js index 65943207811..caf7363cb96 100644 --- a/packages/bg_BG/index.js +++ b/packages/bg_BG/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/bg_BG/link.js b/packages/bg_BG/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/bg_BG/link.js +++ b/packages/bg_BG/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/bg_BG/package.json b/packages/bg_BG/package.json index c8888142d0c..d82e5222b7e 100644 --- a/packages/bg_BG/package.json +++ b/packages/bg_BG/package.json @@ -6,6 +6,10 @@ "cspell-dict-bg-bg-link": "./link.js", "cspell-dict-bg-bg-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"bg_BG.dic\" -o .", "test": "hunspell-reader words -n 1000 \"bg_BG.dic\" | cspell -v -c ./cspell-ext.json \"--local=bg\" \"--languageId=*\" stdin", diff --git a/packages/bg_BG/unlink.js b/packages/bg_BG/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/bg_BG/unlink.js +++ b/packages/bg_BG/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/bg_BG/util.js b/packages/bg_BG/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/bg_BG/util.js +++ b/packages/bg_BG/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/ca/index.js b/packages/ca/index.js index 65943207811..caf7363cb96 100644 --- a/packages/ca/index.js +++ b/packages/ca/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/ca/link.js b/packages/ca/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/ca/link.js +++ b/packages/ca/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/ca/package.json b/packages/ca/package.json index 18221984b63..ec621df2334 100644 --- a/packages/ca/package.json +++ b/packages/ca/package.json @@ -6,6 +6,10 @@ "cspell-dict-ca-link": "./link.js", "cspell-dict-ca-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 cspell-tools compile-trie \"ca.dic\" -o .", "test": "hunspell-reader words -n 1000 \"ca.dic\" | cspell -v -c ./cspell-ext.json --local=ca --languageId=* stdin", diff --git a/packages/ca/unlink.js b/packages/ca/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/ca/unlink.js +++ b/packages/ca/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/ca/util.js b/packages/ca/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/ca/util.js +++ b/packages/ca/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/city-names-finland/index.js b/packages/city-names-finland/index.js index 65943207811..caf7363cb96 100644 --- a/packages/city-names-finland/index.js +++ b/packages/city-names-finland/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/city-names-finland/link.js b/packages/city-names-finland/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/city-names-finland/link.js +++ b/packages/city-names-finland/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/city-names-finland/package.json b/packages/city-names-finland/package.json index 46b5b724f67..edc081560f3 100644 --- a/packages/city-names-finland/package.json +++ b/packages/city-names-finland/package.json @@ -6,6 +6,10 @@ "cspell-dict-city-names-finland-link": "./link.js", "cspell-dict-city-names-finland-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"city-names-finland.txt\" -o .", "test": "head -n 100 \"city-names-finland.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=* stdin", diff --git a/packages/city-names-finland/unlink.js b/packages/city-names-finland/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/city-names-finland/unlink.js +++ b/packages/city-names-finland/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/city-names-finland/util.js b/packages/city-names-finland/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/city-names-finland/util.js +++ b/packages/city-names-finland/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/companies/index.js b/packages/companies/index.js index 65943207811..caf7363cb96 100644 --- a/packages/companies/index.js +++ b/packages/companies/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/companies/link.js b/packages/companies/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/companies/link.js +++ b/packages/companies/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/companies/package.json b/packages/companies/package.json index b31820d0c03..6071c74c700 100644 --- a/packages/companies/package.json +++ b/packages/companies/package.json @@ -6,6 +6,10 @@ "cspell-dict-companies-link": "./link.js", "cspell-dict-companies-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"companies.txt\" -o .", "test": "head -n 100 \"companies.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=* stdin", diff --git a/packages/companies/unlink.js b/packages/companies/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/companies/unlink.js +++ b/packages/companies/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/companies/util.js b/packages/companies/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/companies/util.js +++ b/packages/companies/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/cpp/index.js b/packages/cpp/index.js index 65943207811..caf7363cb96 100644 --- a/packages/cpp/index.js +++ b/packages/cpp/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/cpp/link.js b/packages/cpp/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/cpp/link.js +++ b/packages/cpp/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/cpp/package.json b/packages/cpp/package.json index af92b37efde..203a33eaaf3 100644 --- a/packages/cpp/package.json +++ b/packages/cpp/package.json @@ -6,6 +6,10 @@ "cspell-dict-cpp-link": "./link.js", "cspell-dict-cpp-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"cpp.txt\" -o .", "test": "head -n 100 \"cpp.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=cpp stdin", diff --git a/packages/cpp/unlink.js b/packages/cpp/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/cpp/unlink.js +++ b/packages/cpp/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/cpp/util.js b/packages/cpp/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/cpp/util.js +++ b/packages/cpp/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/cryptocurrencies/index.js b/packages/cryptocurrencies/index.js index 65943207811..caf7363cb96 100644 --- a/packages/cryptocurrencies/index.js +++ b/packages/cryptocurrencies/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/cryptocurrencies/link.js b/packages/cryptocurrencies/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/cryptocurrencies/link.js +++ b/packages/cryptocurrencies/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/cryptocurrencies/package.json b/packages/cryptocurrencies/package.json index d01c3e0e9d9..980efbc9fa1 100644 --- a/packages/cryptocurrencies/package.json +++ b/packages/cryptocurrencies/package.json @@ -6,6 +6,10 @@ "cspell-dict-cryptocurrencies-link": "./link.js", "cspell-dict-cryptocurrencies-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"cryptocurrencies.txt\" -o .", "test": "head -n 100 \"cryptocurrencies.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=*\" stdin", diff --git a/packages/cryptocurrencies/unlink.js b/packages/cryptocurrencies/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/cryptocurrencies/unlink.js +++ b/packages/cryptocurrencies/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/cryptocurrencies/util.js b/packages/cryptocurrencies/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/cryptocurrencies/util.js +++ b/packages/cryptocurrencies/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/cs_CZ/index.js b/packages/cs_CZ/index.js index 65943207811..caf7363cb96 100644 --- a/packages/cs_CZ/index.js +++ b/packages/cs_CZ/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/cs_CZ/link.js b/packages/cs_CZ/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/cs_CZ/link.js +++ b/packages/cs_CZ/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/cs_CZ/package.json b/packages/cs_CZ/package.json index cf6f7fdc869..23cce772e25 100644 --- a/packages/cs_CZ/package.json +++ b/packages/cs_CZ/package.json @@ -6,6 +6,10 @@ "cspell-dict-cs-cz-link": "./link.js", "cspell-dict-cs-cz-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 cspell-tools compile-trie \"Czech.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Czech.dic\" | cspell -v -c ./cspell-ext.json --local=cs --languageId=* stdin", diff --git a/packages/cs_CZ/unlink.js b/packages/cs_CZ/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/cs_CZ/unlink.js +++ b/packages/cs_CZ/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/cs_CZ/util.js b/packages/cs_CZ/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/cs_CZ/util.js +++ b/packages/cs_CZ/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/csharp/index.js b/packages/csharp/index.js index 65943207811..caf7363cb96 100644 --- a/packages/csharp/index.js +++ b/packages/csharp/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/csharp/link.js b/packages/csharp/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/csharp/link.js +++ b/packages/csharp/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/csharp/package.json b/packages/csharp/package.json index dcf6419eed4..8b3bdc24562 100644 --- a/packages/csharp/package.json +++ b/packages/csharp/package.json @@ -6,6 +6,10 @@ "cspell-dict-csharp-link": "./link.js", "cspell-dict-csharp-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"csharp.txt\" -o .", "test": "head -n 100 \"csharp.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=csharp\" stdin", diff --git a/packages/csharp/unlink.js b/packages/csharp/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/csharp/unlink.js +++ b/packages/csharp/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/csharp/util.js b/packages/csharp/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/csharp/util.js +++ b/packages/csharp/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/css/index.js b/packages/css/index.js index 65943207811..caf7363cb96 100644 --- a/packages/css/index.js +++ b/packages/css/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/css/link.js b/packages/css/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/css/link.js +++ b/packages/css/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/css/package.json b/packages/css/package.json index fe37e428d23..57f512579bd 100644 --- a/packages/css/package.json +++ b/packages/css/package.json @@ -6,6 +6,10 @@ "cspell-dict-css-link": "./link.js", "cspell-dict-css-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"css.txt\" -o .", "test": "head -n 100 \"css.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=css\" stdin", diff --git a/packages/css/unlink.js b/packages/css/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/css/unlink.js +++ b/packages/css/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/css/util.js b/packages/css/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/css/util.js +++ b/packages/css/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/da_DK/index.js b/packages/da_DK/index.js index 65943207811..caf7363cb96 100644 --- a/packages/da_DK/index.js +++ b/packages/da_DK/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/da_DK/link.js b/packages/da_DK/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/da_DK/link.js +++ b/packages/da_DK/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/da_DK/package.json b/packages/da_DK/package.json index 81c2041bbaa..01a694baa22 100644 --- a/packages/da_DK/package.json +++ b/packages/da_DK/package.json @@ -6,6 +6,10 @@ "cspell-dict-da-dk-link": "./link.js", "cspell-dict-da-dk-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"da_DK.dic\" -o .", "test": "hunspell-reader words -n 1000 \"da_DK.dic\" | cspell -v -c ./cspell-ext.json --local=da --languageId=* stdin", diff --git a/packages/da_DK/unlink.js b/packages/da_DK/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/da_DK/unlink.js +++ b/packages/da_DK/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/da_DK/util.js b/packages/da_DK/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/da_DK/util.js +++ b/packages/da_DK/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/de_DE/index.js b/packages/de_DE/index.js index 65943207811..caf7363cb96 100644 --- a/packages/de_DE/index.js +++ b/packages/de_DE/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/de_DE/link.js b/packages/de_DE/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/de_DE/link.js +++ b/packages/de_DE/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/de_DE/package.json b/packages/de_DE/package.json index f44a4dbc384..5704c80b12b 100644 --- a/packages/de_DE/package.json +++ b/packages/de_DE/package.json @@ -6,6 +6,10 @@ "cspell-dict-de-de-link": "./link.js", "cspell-dict-de-de-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 cspell-tools compile-trie \"German_de_DE.dic\" -o .", "test": "hunspell-reader words -n 1000 \"German_de_DE.dic\" | cspell -v -c ./cspell-ext.json --local=de --languageId=* stdin", diff --git a/packages/de_DE/unlink.js b/packages/de_DE/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/de_DE/unlink.js +++ b/packages/de_DE/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/de_DE/util.js b/packages/de_DE/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/de_DE/util.js +++ b/packages/de_DE/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/django/index.js b/packages/django/index.js index 65943207811..caf7363cb96 100644 --- a/packages/django/index.js +++ b/packages/django/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/django/link.js b/packages/django/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/django/link.js +++ b/packages/django/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/django/package.json b/packages/django/package.json index 0a5367d0c34..a85c86ac99b 100644 --- a/packages/django/package.json +++ b/packages/django/package.json @@ -6,6 +6,10 @@ "cspell-dict-django-link": "./link.js", "cspell-dict-django-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"django.txt\" -o .", "test": "head -n 100 \"django.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=python stdin", diff --git a/packages/django/unlink.js b/packages/django/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/django/unlink.js +++ b/packages/django/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/django/util.js b/packages/django/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/django/util.js +++ b/packages/django/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/dotnet/index.js b/packages/dotnet/index.js index 65943207811..caf7363cb96 100644 --- a/packages/dotnet/index.js +++ b/packages/dotnet/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/dotnet/link.js b/packages/dotnet/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/dotnet/link.js +++ b/packages/dotnet/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/dotnet/package.json b/packages/dotnet/package.json index 9af1b58bc53..aa00c8443ab 100644 --- a/packages/dotnet/package.json +++ b/packages/dotnet/package.json @@ -6,6 +6,10 @@ "cspell-dict-dotnet-link": "./link.js", "cspell-dict-dotnet-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"dotnet.txt\" -o .", "test": "head -n 100 \"dotnet.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=cs stdin", diff --git a/packages/dotnet/unlink.js b/packages/dotnet/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/dotnet/unlink.js +++ b/packages/dotnet/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/dotnet/util.js b/packages/dotnet/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/dotnet/util.js +++ b/packages/dotnet/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/el/package.json b/packages/el/package.json index 7d9a7721198..e4772dcbfd2 100644 --- a/packages/el/package.json +++ b/packages/el/package.json @@ -6,6 +6,10 @@ "cspell-dict-el-link": "./link.js", "cspell-dict-el-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "compile-all-caps": "node ./tools/toCaps ./src/Greek.txt ./src/Greek.ALLCAPS.txt", "build-dictionary": "cross-env NODE_OPTIONS=--max_old_space_size=4096 cspell-tools compile-trie --merge el_GR src/hunspell/el-GR.dic src/Greek.txt src/Greek.ALLCAPS.txt -o .", diff --git a/packages/elixir/index.js b/packages/elixir/index.js index 65943207811..caf7363cb96 100644 --- a/packages/elixir/index.js +++ b/packages/elixir/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/elixir/link.js b/packages/elixir/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/elixir/link.js +++ b/packages/elixir/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/elixir/package.json b/packages/elixir/package.json index 84c9846b19f..da6124cac6f 100644 --- a/packages/elixir/package.json +++ b/packages/elixir/package.json @@ -6,6 +6,10 @@ "cspell-dict-elixir-link": "./link.js", "cspell-dict-elixir-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"elixir.txt\" -o .", "test": "head -n 100 \"elixir.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=elixir stdin", diff --git a/packages/elixir/unlink.js b/packages/elixir/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/elixir/unlink.js +++ b/packages/elixir/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/elixir/util.js b/packages/elixir/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/elixir/util.js +++ b/packages/elixir/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/en_GB/index.js b/packages/en_GB/index.js index 65943207811..caf7363cb96 100644 --- a/packages/en_GB/index.js +++ b/packages/en_GB/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/en_GB/link.js b/packages/en_GB/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/en_GB/link.js +++ b/packages/en_GB/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/en_GB/package.json b/packages/en_GB/package.json index c899b6af534..fbfcaeb4568 100644 --- a/packages/en_GB/package.json +++ b/packages/en_GB/package.json @@ -6,6 +6,10 @@ "cspell-dict-en-gb-link": "./link.js", "cspell-dict-en-gb-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "npm run compile", "checksum": "shasum -c checksum.txt", diff --git a/packages/en_GB/unlink.js b/packages/en_GB/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/en_GB/unlink.js +++ b/packages/en_GB/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/en_GB/util.js b/packages/en_GB/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/en_GB/util.js +++ b/packages/en_GB/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/en_US/index.js b/packages/en_US/index.js index 65943207811..caf7363cb96 100644 --- a/packages/en_US/index.js +++ b/packages/en_US/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/en_US/link.js b/packages/en_US/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/en_US/link.js +++ b/packages/en_US/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/en_US/package.json b/packages/en_US/package.json index 1d72059cc5a..6b46c045ec5 100644 --- a/packages/en_US/package.json +++ b/packages/en_US/package.json @@ -6,6 +6,10 @@ "cspell-dict-en-us-link": "./link.js", "cspell-dict-en-us-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "npm run compile", "checksum": "shasum -c checksum.txt", diff --git a/packages/en_US/unlink.js b/packages/en_US/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/en_US/unlink.js +++ b/packages/en_US/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/en_US/util.js b/packages/en_US/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/en_US/util.js +++ b/packages/en_US/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/eo/index.js b/packages/eo/index.js index 65943207811..caf7363cb96 100644 --- a/packages/eo/index.js +++ b/packages/eo/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/eo/link.js b/packages/eo/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/eo/link.js +++ b/packages/eo/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/eo/package.json b/packages/eo/package.json index 09174834e95..8234305e855 100644 --- a/packages/eo/package.json +++ b/packages/eo/package.json @@ -6,6 +6,10 @@ "cspell-dict-eo-link": "./link.js", "cspell-dict-eo-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 cspell-tools compile-trie \"eo.dic\" -o .", "test": "hunspell-reader words -n 1000 \"eo.dic\" | cspell -v -c ./cspell-ext.json \"--local=eo\" \"--languageId=*\" stdin", diff --git a/packages/eo/unlink.js b/packages/eo/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/eo/unlink.js +++ b/packages/eo/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/eo/util.js b/packages/eo/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/eo/util.js +++ b/packages/eo/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/es_ES/index.js b/packages/es_ES/index.js index 65943207811..caf7363cb96 100644 --- a/packages/es_ES/index.js +++ b/packages/es_ES/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/es_ES/link.js b/packages/es_ES/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/es_ES/link.js +++ b/packages/es_ES/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/es_ES/package.json b/packages/es_ES/package.json index 7f23eed4d7b..cde8e09e70b 100644 --- a/packages/es_ES/package.json +++ b/packages/es_ES/package.json @@ -6,6 +6,10 @@ "cspell-dict-es-es-link": "./link.js", "cspell-dict-es-es-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"Spanish.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Spanish.dic\" | cspell -v -c ./cspell-ext.json --local=es --languageId=* stdin", diff --git a/packages/es_ES/unlink.js b/packages/es_ES/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/es_ES/unlink.js +++ b/packages/es_ES/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/es_ES/util.js b/packages/es_ES/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/es_ES/util.js +++ b/packages/es_ES/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/fa_IR/index.js b/packages/fa_IR/index.js index 65943207811..caf7363cb96 100644 --- a/packages/fa_IR/index.js +++ b/packages/fa_IR/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/fa_IR/link.js b/packages/fa_IR/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/fa_IR/link.js +++ b/packages/fa_IR/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/fa_IR/package.json b/packages/fa_IR/package.json index 3abdf0e8c8f..abc70b890b2 100644 --- a/packages/fa_IR/package.json +++ b/packages/fa_IR/package.json @@ -6,6 +6,10 @@ "cspell-dict-fa-ir-link": "./link.js", "cspell-dict-fa-ir-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"hunspell/fa-IR.dic\" -o .", "test": "hunspell-reader words -n 1000 \"hunspell/fa-IR.dic\" | cspell -v -c ./cspell-ext.json --local=fa --languageId=* stdin", diff --git a/packages/fa_IR/unlink.js b/packages/fa_IR/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/fa_IR/unlink.js +++ b/packages/fa_IR/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/fa_IR/util.js b/packages/fa_IR/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/fa_IR/util.js +++ b/packages/fa_IR/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/filetypes/index.js b/packages/filetypes/index.js index 65943207811..caf7363cb96 100644 --- a/packages/filetypes/index.js +++ b/packages/filetypes/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/filetypes/link.js b/packages/filetypes/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/filetypes/link.js +++ b/packages/filetypes/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/filetypes/package.json b/packages/filetypes/package.json index 04f98b5d300..4e510af046c 100644 --- a/packages/filetypes/package.json +++ b/packages/filetypes/package.json @@ -6,6 +6,10 @@ "cspell-dict-filetypes-link": "./link.js", "cspell-dict-filetypes-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"filetypes.txt\" -o .", "test": "head -n 100 \"filetypes.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=*\" stdin", diff --git a/packages/filetypes/unlink.js b/packages/filetypes/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/filetypes/unlink.js +++ b/packages/filetypes/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/filetypes/util.js b/packages/filetypes/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/filetypes/util.js +++ b/packages/filetypes/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/fonts/index.js b/packages/fonts/index.js index 65943207811..caf7363cb96 100644 --- a/packages/fonts/index.js +++ b/packages/fonts/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/fonts/link.js b/packages/fonts/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/fonts/link.js +++ b/packages/fonts/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/fonts/package.json b/packages/fonts/package.json index f792e990489..47db3c4ac18 100644 --- a/packages/fonts/package.json +++ b/packages/fonts/package.json @@ -6,6 +6,10 @@ "cspell-dict-fonts-link": "./link.js", "cspell-dict-fonts-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"fonts.txt\" -o .", "test": "head -n 100 \"fonts.txt\" | cspell -v -c ./cspell.json \"--local=*\" \"--languageId=*\" stdin", diff --git a/packages/fonts/unlink.js b/packages/fonts/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/fonts/unlink.js +++ b/packages/fonts/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/fonts/util.js b/packages/fonts/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/fonts/util.js +++ b/packages/fonts/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/fr_FR/index.js b/packages/fr_FR/index.js index 65943207811..caf7363cb96 100644 --- a/packages/fr_FR/index.js +++ b/packages/fr_FR/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/fr_FR/link.js b/packages/fr_FR/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/fr_FR/link.js +++ b/packages/fr_FR/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/fr_FR/package.json b/packages/fr_FR/package.json index c9a5356b1c9..6ba75533a46 100644 --- a/packages/fr_FR/package.json +++ b/packages/fr_FR/package.json @@ -6,6 +6,10 @@ "cspell-dict-fr-fr-link": "./link.js", "cspell-dict-fr-fr-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"French.dic\" -o .", "test-dictionary": "hunspell-reader words -n 1000 \"French.dic\" | cspell -v -c ./cspell-ext.json --local=fr --languageId=* stdin", diff --git a/packages/fr_FR/unlink.js b/packages/fr_FR/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/fr_FR/unlink.js +++ b/packages/fr_FR/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/fr_FR/util.js b/packages/fr_FR/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/fr_FR/util.js +++ b/packages/fr_FR/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/fr_FR_90/index.js b/packages/fr_FR_90/index.js index 65943207811..caf7363cb96 100644 --- a/packages/fr_FR_90/index.js +++ b/packages/fr_FR_90/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/fr_FR_90/link.js b/packages/fr_FR_90/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/fr_FR_90/link.js +++ b/packages/fr_FR_90/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/fr_FR_90/package.json b/packages/fr_FR_90/package.json index 603547a3432..19ae324686e 100644 --- a/packages/fr_FR_90/package.json +++ b/packages/fr_FR_90/package.json @@ -6,6 +6,10 @@ "cspell-dict-fr-reforme-link": "./link.js", "cspell-dict-fr-reforme-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"fr-reforme1990.dic\" -o .", "test": "hunspell-reader words -n 1000 \"fr-reforme1990.dic\" | cspell -v -c ./cspell-ext.json \"--local=fr\" \"--languageId=*\" stdin", diff --git a/packages/fr_FR_90/unlink.js b/packages/fr_FR_90/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/fr_FR_90/unlink.js +++ b/packages/fr_FR_90/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/fr_FR_90/util.js b/packages/fr_FR_90/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/fr_FR_90/util.js +++ b/packages/fr_FR_90/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/fullstack/index.js b/packages/fullstack/index.js index 65943207811..caf7363cb96 100644 --- a/packages/fullstack/index.js +++ b/packages/fullstack/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/fullstack/link.js b/packages/fullstack/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/fullstack/link.js +++ b/packages/fullstack/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/fullstack/package.json b/packages/fullstack/package.json index a1217dae125..d4cee81ba0e 100644 --- a/packages/fullstack/package.json +++ b/packages/fullstack/package.json @@ -6,6 +6,10 @@ "cspell-dict-fullstack-link": "./link.js", "cspell-dict-fullstack-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"fullstack.txt\" -o .", "test": "head -n 100 \"fullstack.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=php stdin", diff --git a/packages/fullstack/unlink.js b/packages/fullstack/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/fullstack/unlink.js +++ b/packages/fullstack/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/fullstack/util.js b/packages/fullstack/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/fullstack/util.js +++ b/packages/fullstack/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/golang/index.js b/packages/golang/index.js index 65943207811..caf7363cb96 100644 --- a/packages/golang/index.js +++ b/packages/golang/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/golang/link.js b/packages/golang/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/golang/link.js +++ b/packages/golang/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/golang/package.json b/packages/golang/package.json index 2052732918e..c19e482424d 100644 --- a/packages/golang/package.json +++ b/packages/golang/package.json @@ -6,6 +6,10 @@ "cspell-dict-golang-link": "./link.js", "cspell-dict-golang-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"go.txt\" -o .", "test": "head -n 100 \"go.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=go stdin", diff --git a/packages/golang/unlink.js b/packages/golang/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/golang/unlink.js +++ b/packages/golang/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/golang/util.js b/packages/golang/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/golang/util.js +++ b/packages/golang/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/haskell/index.js b/packages/haskell/index.js index 65943207811..caf7363cb96 100644 --- a/packages/haskell/index.js +++ b/packages/haskell/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/haskell/link.js b/packages/haskell/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/haskell/link.js +++ b/packages/haskell/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/haskell/package.json b/packages/haskell/package.json index e67eb3bd48b..776fe49f56b 100644 --- a/packages/haskell/package.json +++ b/packages/haskell/package.json @@ -6,6 +6,10 @@ "cspell-dict-haskell-link": "./link.js", "cspell-dict-haskell-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"haskell.txt\" -o .", "test": "head -n 100 \"haskell.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=haskell\" stdin", diff --git a/packages/haskell/unlink.js b/packages/haskell/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/haskell/unlink.js +++ b/packages/haskell/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/haskell/util.js b/packages/haskell/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/haskell/util.js +++ b/packages/haskell/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/he/index.js b/packages/he/index.js index 65943207811..caf7363cb96 100644 --- a/packages/he/index.js +++ b/packages/he/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/he/link.js b/packages/he/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/he/link.js +++ b/packages/he/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/he/package.json b/packages/he/package.json index a8c782ffdd0..e6571c29e7b 100644 --- a/packages/he/package.json +++ b/packages/he/package.json @@ -6,6 +6,10 @@ "cspell-dict-he-link": "./link.js", "cspell-dict-he-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie -m 0 \"hunspell/he.dic\" -o .", "test": "hunspell-reader words -m 0 -n 1000 \"hunspell/he.dic\" | cspell -v -c ./cspell-ext.json --local=he --languageId=* stdin", diff --git a/packages/he/unlink.js b/packages/he/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/he/unlink.js +++ b/packages/he/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/he/util.js b/packages/he/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/he/util.js +++ b/packages/he/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/hr_HR/index.js b/packages/hr_HR/index.js index 65943207811..caf7363cb96 100644 --- a/packages/hr_HR/index.js +++ b/packages/hr_HR/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/hr_HR/link.js b/packages/hr_HR/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/hr_HR/link.js +++ b/packages/hr_HR/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/hr_HR/package.json b/packages/hr_HR/package.json index 47cdcbccd25..f42cc009a22 100644 --- a/packages/hr_HR/package.json +++ b/packages/hr_HR/package.json @@ -6,6 +6,10 @@ "cspell-dict-hr-hr-link": "./link.js", "cspell-dict-hr-hr-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 cspell-tools compile-trie \"hr_HR.dic\" -o .", "test": "hunspell-reader words -n 1000 \"hr_HR.dic\" | cspell -v -c ./cspell-ext.json \"--local=hr,hr-HR\" \"--languageId=*\" stdin", diff --git a/packages/hr_HR/unlink.js b/packages/hr_HR/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/hr_HR/unlink.js +++ b/packages/hr_HR/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/hr_HR/util.js b/packages/hr_HR/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/hr_HR/util.js +++ b/packages/hr_HR/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/html-symbol-entities/index.js b/packages/html-symbol-entities/index.js index 65943207811..caf7363cb96 100644 --- a/packages/html-symbol-entities/index.js +++ b/packages/html-symbol-entities/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/html-symbol-entities/link.js b/packages/html-symbol-entities/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/html-symbol-entities/link.js +++ b/packages/html-symbol-entities/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/html-symbol-entities/package.json b/packages/html-symbol-entities/package.json index bb1c6adaafa..6b05e1d0cfa 100644 --- a/packages/html-symbol-entities/package.json +++ b/packages/html-symbol-entities/package.json @@ -6,6 +6,10 @@ "cspell-dict-html-symbol-entities-link": "./link.js", "cspell-dict-html-symbol-entities-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"entities.txt\" -o .", "test": "head -n 100 \"entities.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=html stdin", diff --git a/packages/html-symbol-entities/unlink.js b/packages/html-symbol-entities/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/html-symbol-entities/unlink.js +++ b/packages/html-symbol-entities/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/html-symbol-entities/util.js b/packages/html-symbol-entities/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/html-symbol-entities/util.js +++ b/packages/html-symbol-entities/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/html/index.js b/packages/html/index.js index 65943207811..caf7363cb96 100644 --- a/packages/html/index.js +++ b/packages/html/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/html/link.js b/packages/html/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/html/link.js +++ b/packages/html/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/html/package.json b/packages/html/package.json index 40158a21028..ae9b949a91a 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -6,6 +6,10 @@ "cspell-dict-html-link": "./link.js", "cspell-dict-html-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 cspell-tools compile \"html.txt\" -o .", "test": "head -n 100 \"html.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=html\" stdin", diff --git a/packages/html/unlink.js b/packages/html/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/html/unlink.js +++ b/packages/html/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/html/util.js b/packages/html/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/html/util.js +++ b/packages/html/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/it_IT/index.js b/packages/it_IT/index.js index 65943207811..caf7363cb96 100644 --- a/packages/it_IT/index.js +++ b/packages/it_IT/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/it_IT/link.js b/packages/it_IT/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/it_IT/link.js +++ b/packages/it_IT/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/it_IT/package.json b/packages/it_IT/package.json index 1ec3dc36432..09a70c376ef 100644 --- a/packages/it_IT/package.json +++ b/packages/it_IT/package.json @@ -6,6 +6,10 @@ "cspell-dict-it-it-link": "./link.js", "cspell-dict-it-it-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=8092 cspell-tools compile-trie \"it_IT.dic\" -o .", "test": "hunspell-reader words -n 1000 \"it_IT.dic\" | cspell -v -c ./cspell-ext.json \"--local=it,it-IT\" \"--languageId=*\" stdin", diff --git a/packages/it_IT/unlink.js b/packages/it_IT/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/it_IT/unlink.js +++ b/packages/it_IT/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/it_IT/util.js b/packages/it_IT/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/it_IT/util.js +++ b/packages/it_IT/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/java/index.js b/packages/java/index.js index 65943207811..caf7363cb96 100644 --- a/packages/java/index.js +++ b/packages/java/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/java/link.js b/packages/java/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/java/link.js +++ b/packages/java/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/java/package.json b/packages/java/package.json index 1d15d688277..294e53268a9 100644 --- a/packages/java/package.json +++ b/packages/java/package.json @@ -6,6 +6,10 @@ "cspell-dict-java-link": "./link.js", "cspell-dict-java-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"java.txt\" -o .", "test": "head -n 100 \"java.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=java stdin", diff --git a/packages/java/unlink.js b/packages/java/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/java/unlink.js +++ b/packages/java/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/java/util.js b/packages/java/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/java/util.js +++ b/packages/java/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/latex/index.js b/packages/latex/index.js index 65943207811..caf7363cb96 100644 --- a/packages/latex/index.js +++ b/packages/latex/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/latex/link.js b/packages/latex/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/latex/link.js +++ b/packages/latex/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/latex/package.json b/packages/latex/package.json index 411e9fa594d..61ffbaeb000 100644 --- a/packages/latex/package.json +++ b/packages/latex/package.json @@ -6,6 +6,10 @@ "cspell-dict-latex-link": "./link.js", "cspell-dict-latex-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"latex.txt\" -o .", "test": "head -n 1000 \"latex.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=latex stdin", diff --git a/packages/latex/unlink.js b/packages/latex/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/latex/unlink.js +++ b/packages/latex/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/latex/util.js b/packages/latex/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/latex/util.js +++ b/packages/latex/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/lorem-ipsum/index.js b/packages/lorem-ipsum/index.js index 65943207811..caf7363cb96 100644 --- a/packages/lorem-ipsum/index.js +++ b/packages/lorem-ipsum/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/lorem-ipsum/link.js b/packages/lorem-ipsum/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/lorem-ipsum/link.js +++ b/packages/lorem-ipsum/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/lorem-ipsum/package.json b/packages/lorem-ipsum/package.json index ea5ad858b02..7318eead175 100644 --- a/packages/lorem-ipsum/package.json +++ b/packages/lorem-ipsum/package.json @@ -6,6 +6,10 @@ "cspell-dict-lorem-ipsum-link": "./link.js", "cspell-dict-lorem-ipsum-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"dictionary.txt\" -o .", "test": "head -n 1000 \"dictionary.txt\" | cspell -v -c ./cspell-ext.json --local=lorem --languageId=* stdin", diff --git a/packages/lorem-ipsum/unlink.js b/packages/lorem-ipsum/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/lorem-ipsum/unlink.js +++ b/packages/lorem-ipsum/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/lorem-ipsum/util.js b/packages/lorem-ipsum/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/lorem-ipsum/util.js +++ b/packages/lorem-ipsum/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/lt_LT/index.js b/packages/lt_LT/index.js index 65943207811..caf7363cb96 100644 --- a/packages/lt_LT/index.js +++ b/packages/lt_LT/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/lt_LT/link.js b/packages/lt_LT/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/lt_LT/link.js +++ b/packages/lt_LT/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/lt_LT/package.json b/packages/lt_LT/package.json index 91d76104866..a7ed02118a8 100644 --- a/packages/lt_LT/package.json +++ b/packages/lt_LT/package.json @@ -6,6 +6,10 @@ "cspell-dict-lt-lt-link": "./link.js", "cspell-dict-lt-lt-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=12288 cspell-tools compile-trie \"lt_LT.dic\" -o .", "test": "hunspell-reader words -n 1000 \"lt_LT.dic\" | cspell -v -c ./cspell-ext.json --local=lt --languageId=* stdin", diff --git a/packages/lt_LT/unlink.js b/packages/lt_LT/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/lt_LT/unlink.js +++ b/packages/lt_LT/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/lt_LT/util.js b/packages/lt_LT/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/lt_LT/util.js +++ b/packages/lt_LT/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/lua/index.js b/packages/lua/index.js index 65943207811..caf7363cb96 100644 --- a/packages/lua/index.js +++ b/packages/lua/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/lua/link.js b/packages/lua/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/lua/link.js +++ b/packages/lua/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/lua/package.json b/packages/lua/package.json index 879cfa87f7b..4a91895feba 100644 --- a/packages/lua/package.json +++ b/packages/lua/package.json @@ -6,6 +6,10 @@ "cspell-dict-lua-link": "./link.js", "cspell-dict-lua-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"lua.txt\" -o .", "test": "head -n 1000 \"lua.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=lua stdin", diff --git a/packages/lua/unlink.js b/packages/lua/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/lua/unlink.js +++ b/packages/lua/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/lua/util.js b/packages/lua/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/lua/util.js +++ b/packages/lua/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/medicalterms/index.js b/packages/medicalterms/index.js index 65943207811..caf7363cb96 100644 --- a/packages/medicalterms/index.js +++ b/packages/medicalterms/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/medicalterms/link.js b/packages/medicalterms/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/medicalterms/link.js +++ b/packages/medicalterms/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/medicalterms/package.json b/packages/medicalterms/package.json index 9c9850cdc01..5e15ddff881 100644 --- a/packages/medicalterms/package.json +++ b/packages/medicalterms/package.json @@ -6,6 +6,10 @@ "cspell-dict-medicalterms-link": "./link.js", "cspell-dict-medicalterms-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"medicalterms-en.txt\" -o .", "test": "head -n 100 \"medicalterms-en.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=* stdin", diff --git a/packages/medicalterms/unlink.js b/packages/medicalterms/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/medicalterms/unlink.js +++ b/packages/medicalterms/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/medicalterms/util.js b/packages/medicalterms/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/medicalterms/util.js +++ b/packages/medicalterms/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/nl_NL/index.js b/packages/nl_NL/index.js index 65943207811..caf7363cb96 100644 --- a/packages/nl_NL/index.js +++ b/packages/nl_NL/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/nl_NL/link.js b/packages/nl_NL/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/nl_NL/link.js +++ b/packages/nl_NL/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/nl_NL/package.json b/packages/nl_NL/package.json index 4e853e0779f..01d5cfd6f08 100644 --- a/packages/nl_NL/package.json +++ b/packages/nl_NL/package.json @@ -6,6 +6,10 @@ "cspell-dict-nl-nl-link": "./link.js", "cspell-dict-nl-nl-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"Dutch.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Dutch.dic\" | cspell -v -c ./cspell-ext.json --local=nl --languageId=* stdin", diff --git a/packages/nl_NL/unlink.js b/packages/nl_NL/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/nl_NL/unlink.js +++ b/packages/nl_NL/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/nl_NL/util.js b/packages/nl_NL/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/nl_NL/util.js +++ b/packages/nl_NL/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/node/index.js b/packages/node/index.js index 65943207811..caf7363cb96 100644 --- a/packages/node/index.js +++ b/packages/node/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/node/link.js b/packages/node/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/node/link.js +++ b/packages/node/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/node/package.json b/packages/node/package.json index ceaed9d9b75..db6130a4b01 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -6,6 +6,10 @@ "cspell-dict-node-link": "./link.js", "cspell-dict-node-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"node.txt\" -o .", "test": "head -n 100 \"node.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=javascript\" stdin", diff --git a/packages/node/unlink.js b/packages/node/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/node/unlink.js +++ b/packages/node/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/node/util.js b/packages/node/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/node/util.js +++ b/packages/node/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/npm/index.js b/packages/npm/index.js index 65943207811..caf7363cb96 100644 --- a/packages/npm/index.js +++ b/packages/npm/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/npm/link.js b/packages/npm/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/npm/link.js +++ b/packages/npm/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/npm/package.json b/packages/npm/package.json index 860603f9c9d..dd3f7a0f8d8 100644 --- a/packages/npm/package.json +++ b/packages/npm/package.json @@ -6,6 +6,10 @@ "cspell-dict-npm-link": "./link.js", "cspell-dict-npm-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"npm.txt\" -o .", "test": "head -n 100 \"npm.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=javascript\" stdin", diff --git a/packages/npm/unlink.js b/packages/npm/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/npm/unlink.js +++ b/packages/npm/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/npm/util.js b/packages/npm/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/npm/util.js +++ b/packages/npm/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/php/index.js b/packages/php/index.js index 65943207811..caf7363cb96 100644 --- a/packages/php/index.js +++ b/packages/php/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/php/link.js b/packages/php/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/php/link.js +++ b/packages/php/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/php/package.json b/packages/php/package.json index 39119bba922..7cd1bc6b64d 100644 --- a/packages/php/package.json +++ b/packages/php/package.json @@ -6,6 +6,10 @@ "cspell-dict-php-link": "./link.js", "cspell-dict-php-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"php.txt\" -o .", "test": "head -n 1000 \"php.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=php stdin", diff --git a/packages/php/unlink.js b/packages/php/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/php/unlink.js +++ b/packages/php/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/php/util.js b/packages/php/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/php/util.js +++ b/packages/php/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/pl_PL/index.js b/packages/pl_PL/index.js index 65943207811..caf7363cb96 100644 --- a/packages/pl_PL/index.js +++ b/packages/pl_PL/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/pl_PL/link.js b/packages/pl_PL/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/pl_PL/link.js +++ b/packages/pl_PL/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/pl_PL/package.json b/packages/pl_PL/package.json index 9e1175a8a6c..c24a0da4130 100644 --- a/packages/pl_PL/package.json +++ b/packages/pl_PL/package.json @@ -6,6 +6,10 @@ "cspell-dict-pl-pl-link": "./link.js", "cspell-dict-pl-pl-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=12288 cspell-tools compile-trie \"pl_pl.dic\" -o .", "test": "hunspell-reader words -n 1000 \"pl_pl.dic\" | cspell -v -c ./cspell-ext.json --local=pl --languageId=* stdin", diff --git a/packages/pl_PL/unlink.js b/packages/pl_PL/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/pl_PL/unlink.js +++ b/packages/pl_PL/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/pl_PL/util.js b/packages/pl_PL/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/pl_PL/util.js +++ b/packages/pl_PL/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/powershell/index.js b/packages/powershell/index.js index 65943207811..caf7363cb96 100644 --- a/packages/powershell/index.js +++ b/packages/powershell/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/powershell/link.js b/packages/powershell/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/powershell/link.js +++ b/packages/powershell/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/powershell/package.json b/packages/powershell/package.json index 65a6cb6609f..9a56872f8a1 100644 --- a/packages/powershell/package.json +++ b/packages/powershell/package.json @@ -6,6 +6,10 @@ "cspell-dict-powershell-link": "./link.js", "cspell-dict-powershell-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"powershell.txt\" -o .", "test": "head -n 100 \"powershell.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=powershell\" stdin", diff --git a/packages/powershell/unlink.js b/packages/powershell/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/powershell/unlink.js +++ b/packages/powershell/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/powershell/util.js b/packages/powershell/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/powershell/util.js +++ b/packages/powershell/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/pt_BR/index.js b/packages/pt_BR/index.js index 65943207811..caf7363cb96 100644 --- a/packages/pt_BR/index.js +++ b/packages/pt_BR/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/pt_BR/link.js b/packages/pt_BR/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/pt_BR/link.js +++ b/packages/pt_BR/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/pt_BR/package.json b/packages/pt_BR/package.json index 041195c127d..620c592ee2b 100644 --- a/packages/pt_BR/package.json +++ b/packages/pt_BR/package.json @@ -6,6 +6,10 @@ "cspell-dict-pt-br-link": "./link.js", "cspell-dict-pt-br-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=12288 cspell-tools compile-trie \"Portuguese-Brazilian.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Portuguese-Brazilian.dic\" | cspell -v -c ./cspell-ext.json --local=pt --languageId=* stdin", diff --git a/packages/pt_BR/unlink.js b/packages/pt_BR/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/pt_BR/unlink.js +++ b/packages/pt_BR/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/pt_BR/util.js b/packages/pt_BR/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/pt_BR/util.js +++ b/packages/pt_BR/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/pt_PT/index.js b/packages/pt_PT/index.js index 65943207811..caf7363cb96 100644 --- a/packages/pt_PT/index.js +++ b/packages/pt_PT/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/pt_PT/link.js b/packages/pt_PT/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/pt_PT/link.js +++ b/packages/pt_PT/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/pt_PT/package.json b/packages/pt_PT/package.json index f64302bf98e..ac0d331e94f 100644 --- a/packages/pt_PT/package.json +++ b/packages/pt_PT/package.json @@ -6,6 +6,10 @@ "cspell-dict-pt-pt-link": "./link.js", "cspell-dict-pt-pt-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"Portuguese-European.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Portuguese-European.dic\" | cspell -v -c ./cspell-ext.json --local=pt --languageId=* stdin", diff --git a/packages/pt_PT/unlink.js b/packages/pt_PT/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/pt_PT/unlink.js +++ b/packages/pt_PT/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/pt_PT/util.js b/packages/pt_PT/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/pt_PT/util.js +++ b/packages/pt_PT/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/python/index.js b/packages/python/index.js index 65943207811..caf7363cb96 100644 --- a/packages/python/index.js +++ b/packages/python/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/python/link.js b/packages/python/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/python/link.js +++ b/packages/python/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/python/package.json b/packages/python/package.json index 1ad5053920e..d73160b8574 100644 --- a/packages/python/package.json +++ b/packages/python/package.json @@ -6,6 +6,10 @@ "cspell-dict-python-link": "./link.js", "cspell-dict-python-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"python.txt\" -o .", "test-dictionary": "head -n 1000 \"python.txt\" | cspell -v -c ./cspell-ext.json --local=* --languageId=python stdin", diff --git a/packages/python/unlink.js b/packages/python/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/python/unlink.js +++ b/packages/python/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/python/util.js b/packages/python/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/python/util.js +++ b/packages/python/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/ru_RU/index.js b/packages/ru_RU/index.js index 65943207811..caf7363cb96 100644 --- a/packages/ru_RU/index.js +++ b/packages/ru_RU/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/ru_RU/link.js b/packages/ru_RU/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/ru_RU/link.js +++ b/packages/ru_RU/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/ru_RU/package.json b/packages/ru_RU/package.json index f1405ca7bb6..e2e075afd6f 100644 --- a/packages/ru_RU/package.json +++ b/packages/ru_RU/package.json @@ -6,6 +6,10 @@ "cspell-dict-ru-ru-link": "./link.js", "cspell-dict-ru-ru-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cat source-files.txt | xargs cross-env NODE_OPTIONS=--max_old_space_size=12288 cspell-tools compile-trie -o . -M ru_ru && npm run gen-checksum", "checksum": "shasum -c checksum.txt", diff --git a/packages/ru_RU/unlink.js b/packages/ru_RU/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/ru_RU/unlink.js +++ b/packages/ru_RU/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/ru_RU/util.js b/packages/ru_RU/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/ru_RU/util.js +++ b/packages/ru_RU/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/ruby/index.js b/packages/ruby/index.js index 65943207811..caf7363cb96 100644 --- a/packages/ruby/index.js +++ b/packages/ruby/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/ruby/link.js b/packages/ruby/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/ruby/link.js +++ b/packages/ruby/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/ruby/package.json b/packages/ruby/package.json index 800b65a2d4e..a3f4000aca2 100644 --- a/packages/ruby/package.json +++ b/packages/ruby/package.json @@ -6,6 +6,10 @@ "cspell-dict-ruby-link": "./link.js", "cspell-dict-ruby-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"ruby.txt\" -o .", "test": "head -n 100 \"ruby.txt\" | cspell -v -c ./cspell-ext.json \"--local=en\" \"--languageId=ruby\" stdin", diff --git a/packages/ruby/unlink.js b/packages/ruby/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/ruby/unlink.js +++ b/packages/ruby/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/ruby/util.js b/packages/ruby/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/ruby/util.js +++ b/packages/ruby/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/russian/index.js b/packages/russian/index.js index 65943207811..caf7363cb96 100644 --- a/packages/russian/index.js +++ b/packages/russian/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/russian/link.js b/packages/russian/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/russian/link.js +++ b/packages/russian/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/russian/package.json b/packages/russian/package.json index ddbc07057c7..7f7b831dc82 100644 --- a/packages/russian/package.json +++ b/packages/russian/package.json @@ -6,6 +6,10 @@ "cspell-dict-russian-link": "./link.js", "cspell-dict-russian-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cross-env NODE_OPTIONS=--max_old_space_size=12288 cspell-tools compile-trie \"Russian.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Russian.dic\" | cspell -v -c ./cspell-ext.json --local=ru --languageId=* stdin", diff --git a/packages/russian/unlink.js b/packages/russian/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/russian/unlink.js +++ b/packages/russian/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/russian/util.js b/packages/russian/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/russian/util.js +++ b/packages/russian/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/rust/index.js b/packages/rust/index.js index 65943207811..caf7363cb96 100644 --- a/packages/rust/index.js +++ b/packages/rust/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/rust/link.js b/packages/rust/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/rust/link.js +++ b/packages/rust/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/rust/package.json b/packages/rust/package.json index 06e9b3ad94b..f1c3718bb7d 100644 --- a/packages/rust/package.json +++ b/packages/rust/package.json @@ -6,6 +6,10 @@ "cspell-dict-rust-link": "./link.js", "cspell-dict-rust-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"rust.txt\" -o .", "prepublishOnly": "npm t", diff --git a/packages/rust/unlink.js b/packages/rust/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/rust/unlink.js +++ b/packages/rust/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/rust/util.js b/packages/rust/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/rust/util.js +++ b/packages/rust/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/scala/index.js b/packages/scala/index.js index 65943207811..caf7363cb96 100644 --- a/packages/scala/index.js +++ b/packages/scala/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/scala/link.js b/packages/scala/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/scala/link.js +++ b/packages/scala/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/scala/package.json b/packages/scala/package.json index fa3c49fdb0f..945ce14a305 100644 --- a/packages/scala/package.json +++ b/packages/scala/package.json @@ -6,6 +6,10 @@ "cspell-dict-scala-link": "./link.js", "cspell-dict-scala-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"scala.txt\" -o .", "prepublishOnly": "npm t", diff --git a/packages/scala/unlink.js b/packages/scala/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/scala/unlink.js +++ b/packages/scala/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/scala/util.js b/packages/scala/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/scala/util.js +++ b/packages/scala/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/scientific_terms_US/index.js b/packages/scientific_terms_US/index.js index 65943207811..caf7363cb96 100644 --- a/packages/scientific_terms_US/index.js +++ b/packages/scientific_terms_US/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/scientific_terms_US/link.js b/packages/scientific_terms_US/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/scientific_terms_US/link.js +++ b/packages/scientific_terms_US/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/scientific_terms_US/package.json b/packages/scientific_terms_US/package.json index fe733b255ca..1ef8fdf22f0 100644 --- a/packages/scientific_terms_US/package.json +++ b/packages/scientific_terms_US/package.json @@ -6,6 +6,10 @@ "cspell-dict-scientific-terms-us-link": "./link.js", "cspell-dict-scientific-terms-us-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"custom_scientific_US.dic.txt\" -o .", "prepublishOnly": "npm t", diff --git a/packages/scientific_terms_US/unlink.js b/packages/scientific_terms_US/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/scientific_terms_US/unlink.js +++ b/packages/scientific_terms_US/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/scientific_terms_US/util.js b/packages/scientific_terms_US/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/scientific_terms_US/util.js +++ b/packages/scientific_terms_US/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/software-terms/index.js b/packages/software-terms/index.js index 65943207811..caf7363cb96 100644 --- a/packages/software-terms/index.js +++ b/packages/software-terms/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/software-terms/link.js b/packages/software-terms/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/software-terms/link.js +++ b/packages/software-terms/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/software-terms/package.json b/packages/software-terms/package.json index e3810703e35..46729c5e95d 100644 --- a/packages/software-terms/package.json +++ b/packages/software-terms/package.json @@ -6,6 +6,10 @@ "cspell-dict-software-terms-link": "./link.js", "cspell-dict-software-terms-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"softwareTerms.txt\" -o .", "test": "head -n 100 \"softwareTerms.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=*\" stdin", diff --git a/packages/software-terms/unlink.js b/packages/software-terms/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/software-terms/unlink.js +++ b/packages/software-terms/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/software-terms/util.js b/packages/software-terms/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/software-terms/util.js +++ b/packages/software-terms/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/sv/index.js b/packages/sv/index.js index 65943207811..caf7363cb96 100644 --- a/packages/sv/index.js +++ b/packages/sv/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/sv/link.js b/packages/sv/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/sv/link.js +++ b/packages/sv/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/sv/package.json b/packages/sv/package.json index 726a402ecf8..677282eab45 100644 --- a/packages/sv/package.json +++ b/packages/sv/package.json @@ -6,6 +6,10 @@ "cspell-dict-sv-link": "./link.js", "cspell-dict-sv-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"Swedish.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Swedish.dic\" | cspell -v -c ./cspell-ext.json --local=sv --languageId=* stdin", diff --git a/packages/sv/unlink.js b/packages/sv/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/sv/unlink.js +++ b/packages/sv/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/sv/util.js b/packages/sv/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/sv/util.js +++ b/packages/sv/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/tr_TR/index.js b/packages/tr_TR/index.js index 65943207811..caf7363cb96 100644 --- a/packages/tr_TR/index.js +++ b/packages/tr_TR/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/tr_TR/link.js b/packages/tr_TR/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/tr_TR/link.js +++ b/packages/tr_TR/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/tr_TR/package.json b/packages/tr_TR/package.json index 559931c000c..05d0e2f5a2f 100644 --- a/packages/tr_TR/package.json +++ b/packages/tr_TR/package.json @@ -6,6 +6,10 @@ "cspell-dict-tr-tr-link": "./link.js", "cspell-dict-tr-tr-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"Turkish.dic\" -o .", "test": "hunspell-reader words -n 1000 \"Turkish.dic\" | cspell -v -c ./cspell-ext.json --local=tr --languageId=* stdin", diff --git a/packages/tr_TR/unlink.js b/packages/tr_TR/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/tr_TR/unlink.js +++ b/packages/tr_TR/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/tr_TR/util.js b/packages/tr_TR/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/tr_TR/util.js +++ b/packages/tr_TR/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/typescript/index.js b/packages/typescript/index.js index 65943207811..caf7363cb96 100644 --- a/packages/typescript/index.js +++ b/packages/typescript/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/typescript/link.js b/packages/typescript/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/packages/typescript/link.js +++ b/packages/typescript/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/typescript/package.json b/packages/typescript/package.json index b8b877e6ea0..3dc05540d1c 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -6,6 +6,10 @@ "cspell-dict-typescript-link": "./link.js", "cspell-dict-typescript-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile \"typescript.txt\" -o .", "test": "head -n 100 \"typescript.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=typescript\" stdin", diff --git a/packages/typescript/unlink.js b/packages/typescript/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/packages/typescript/unlink.js +++ b/packages/typescript/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/typescript/util.js b/packages/typescript/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/typescript/util.js +++ b/packages/typescript/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/uk_UA/index.js b/packages/uk_UA/index.js index 65943207811..caf7363cb96 100644 --- a/packages/uk_UA/index.js +++ b/packages/uk_UA/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/uk_UA/link.js b/packages/uk_UA/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/uk_UA/link.js +++ b/packages/uk_UA/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/uk_UA/package.json b/packages/uk_UA/package.json index d6859efcec9..11f25d2e68e 100644 --- a/packages/uk_UA/package.json +++ b/packages/uk_UA/package.json @@ -6,6 +6,10 @@ "cspell-dict-uk-ua-link": "./link.js", "cspell-dict-uk-ua-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"uk_ua.dic\" -o .", "test": "hunspell-reader words -n 1000 \"uk_ua.dic\" | cspell -v -c ./cspell-ext.json --local=uk --languageId=* stdin", diff --git a/packages/uk_UA/unlink.js b/packages/uk_UA/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/uk_UA/unlink.js +++ b/packages/uk_UA/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/uk_UA/util.js b/packages/uk_UA/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/uk_UA/util.js +++ b/packages/uk_UA/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/packages/vi_VN/index.js b/packages/vi_VN/index.js index 65943207811..caf7363cb96 100644 --- a/packages/vi_VN/index.js +++ b/packages/vi_VN/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/packages/vi_VN/link.js b/packages/vi_VN/link.js index a6ed630828b..5ccff16d6bb 100755 --- a/packages/vi_VN/link.js +++ b/packages/vi_VN/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/packages/vi_VN/package.json b/packages/vi_VN/package.json index a5183d9af90..18b781370f2 100644 --- a/packages/vi_VN/package.json +++ b/packages/vi_VN/package.json @@ -6,6 +6,10 @@ "cspell-dict-vi-vn-link": "./link.js", "cspell-dict-vi-vn-unlink": "./unlink.js" }, + "exports": { + ".": "./index.js", + "./cspell-ext.json": "./cspell-ext.json" + }, "scripts": { "build": "cspell-tools compile-trie \"vi.dic\" -o .", "test": "hunspell-reader words -n 1000 \"vi.dic\" | cspell -v -c ./cspell-ext.json --local=vi --languageId=* stdin", diff --git a/packages/vi_VN/unlink.js b/packages/vi_VN/unlink.js index 19282c9a790..0b31f05953b 100755 --- a/packages/vi_VN/unlink.js +++ b/packages/vi_VN/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/packages/vi_VN/util.js b/packages/vi_VN/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/packages/vi_VN/util.js +++ b/packages/vi_VN/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports); diff --git a/util/index.js b/util/index.js index 65943207811..caf7363cb96 100644 --- a/util/index.js +++ b/util/index.js @@ -1,9 +1,9 @@ 'use strict'; -var util = require('./util'); +const configLocation = require.resolve('./cspell-ext.json'); function getConfigLocation() { - return util.configLocation; + return configLocation; } module.exports = { diff --git a/util/link.js b/util/link.js index a6ed630828b..5ccff16d6bb 100644 --- a/util/link.js +++ b/util/link.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.install(); diff --git a/util/unlink.js b/util/unlink.js index 19282c9a790..0b31f05953b 100644 --- a/util/unlink.js +++ b/util/unlink.js @@ -2,6 +2,6 @@ 'use strict'; -var util = require('./util'); +const util = require('./util'); util.uninstall(); diff --git a/util/util.js b/util/util.js index 98f5cdd72c8..29c9074b32f 100644 --- a/util/util.js +++ b/util/util.js @@ -1,29 +1,30 @@ 'use strict'; // Cspell:word configstore -var Configstore = require('configstore'); -var Path = require('path'); +const Configstore = require('configstore'); -var packageName = 'cspell'; -var importPath = 'import'; -var configLocation = Path.join(__dirname, 'cspell-ext.json'); +const packageName = 'cspell'; +const importPath = 'import'; +const configLocation = require.resolve('./cspell-ext.json'); +/** + * + * @param {Configstore} conf + * @returns {string[]} + */ function getImports(conf) { - var imports = conf.get(importPath); + const imports = conf.get(importPath) || []; - imports = imports || []; if (typeof imports === 'string') { - imports = [imports]; + return [imports]; } return imports; } function install() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - - var imports = getImports(conf); + const conf = new Configstore(packageName); + const imports = getImports(conf); if (imports.indexOf(configLocation) < 0) { imports.push(configLocation); conf.set(importPath, imports); @@ -31,12 +32,9 @@ function install() { } function uninstall() { - var conf = new Configstore(packageName); - /** @type {string[]|string|undefined} */ - var imports = getImports(conf); - - var index = imports.indexOf(configLocation); - + const conf = new Configstore(packageName); + const imports = getImports(conf); + const index = imports.indexOf(configLocation); if (index >= 0) { imports.splice(index, 1); conf.set(importPath, imports);