includable /
cli
| 1 | /* |
||
| 2 | * Copyright (c) 2018 Includable. |
||
| 3 | * Created by Thomas Schoffelen. |
||
| 4 | */ |
||
| 5 | |||
| 6 | View Code Duplication | 'use strict' |
|
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
| 7 | |||
| 8 | const minimatch = require('minimatch') |
||
| 9 | const Module = require('../containers/Module') |
||
| 10 | |||
| 11 | const matchFile = function (options, path) { |
||
| 12 | if (typeof options.paths === 'string') { |
||
| 13 | options.paths = [options.paths] |
||
| 14 | } |
||
| 15 | |||
| 16 | for (var i in options.paths) { |
||
| 17 | if (!options.paths.hasOwnProperty(i)) { |
||
| 18 | continue |
||
| 19 | } |
||
| 20 | if (minimatch(path, options.paths[i])) { |
||
| 21 | return true |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | return false |
||
| 26 | } |
||
| 27 | |||
| 28 | let manifest |
||
| 29 | Module.getManifest(function (manifestObj) { |
||
| 30 | manifest = manifestObj |
||
| 31 | }) |
||
| 32 | |||
| 33 | module.exports = function (path) { |
||
| 34 | var options = manifest.getDevOption('ignore') |
||
| 35 | if (!options || !('paths' in options)) { |
||
| 36 | return false |
||
| 37 | } |
||
| 38 | |||
| 39 | return matchFile(options, path) |
||
| 40 | } |
||
| 41 |