From 7c873e98cbd436a12a118f408ee5799e40284c4c Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 29 May 2020 16:44:14 -0500 Subject: [PATCH] ignored-names-importer --- lib/ignored-names-importer.js | 3 +++ lib/ignored-names.coffee | 7 +++---- lib/tree-view.coffee | 3 ++- package.json | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 lib/ignored-names-importer.js diff --git a/lib/ignored-names-importer.js b/lib/ignored-names-importer.js new file mode 100644 index 00000000..119ff104 --- /dev/null +++ b/lib/ignored-names-importer.js @@ -0,0 +1,3 @@ +export async function ignoredNamesImporter() { + return await import('./ignored-names') +} diff --git a/lib/ignored-names.coffee b/lib/ignored-names.coffee index b1b4f86d..9884c8f1 100644 --- a/lib/ignored-names.coffee +++ b/lib/ignored-names.coffee @@ -1,16 +1,15 @@ -Minimatch = null # Defer requiring until actually needed +# this file is lazy loaded by ignored-names-importer +import minimatch from 'minimatch' export default class IgnoredNames constructor: -> @ignoredPatterns = [] - Minimatch ?= require('minimatch').Minimatch - ignoredNames = atom.config.get('core.ignoredNames') ? [] ignoredNames = [ignoredNames] if typeof ignoredNames is 'string' for ignoredName in ignoredNames when ignoredName try - @ignoredPatterns.push(new Minimatch(ignoredName, matchBase: true, dot: true)) + @ignoredPatterns.push(new minimatch(ignoredName, matchBase: true, dot: true)) catch error atom.notifications.addWarning("Error parsing ignore pattern (#{ignoredName})", detail: error.message) diff --git a/lib/tree-view.coffee b/lib/tree-view.coffee index 1b10237c..af7c3f02 100644 --- a/lib/tree-view.coffee +++ b/lib/tree-view.coffee @@ -10,6 +10,7 @@ import AddDialog from './add-dialog' import MoveDialog from './move-dialog' import CopyDialog from './copy-dialog' IgnoredNames = null # Defer requiring until actually needed +import {ignoredNamesImporter} from './ignored-names-importer.js' import AddProjectsView from './add-projects-view' @@ -332,7 +333,7 @@ export default class TreeView addProjectsViewElement = @element.querySelector('#add-projects-view') @element.removeChild(addProjectsViewElement) if addProjectsViewElement - IgnoredNames ?= await import('./ignored-names') + IgnoredNames ?= await ignoredNamesImporter() @roots = for projectPath in projectPaths stats = fs.lstatSyncNoException(projectPath) diff --git a/package.json b/package.json index 596e31ed..b1e8784e 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,8 @@ "atom" ], "ignore": [ - "/spec/fixtures/" + "/spec/fixtures/", + "lib/ignored-names-importer.js" ] }, "configSchema": {