Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
ignored-names-importer
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed May 29, 2020
1 parent d4688cd commit 7c873e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lib/ignored-names-importer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function ignoredNamesImporter() {
return await import('./ignored-names')
}
7 changes: 3 additions & 4 deletions lib/ignored-names.coffee
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
3 changes: 2 additions & 1 deletion lib/tree-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"atom"
],
"ignore": [
"/spec/fixtures/"
"/spec/fixtures/",
"lib/ignored-names-importer.js"
]
},
"configSchema": {
Expand Down

0 comments on commit 7c873e9

Please sign in to comment.