-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this PR adds the functionality to run `citgm-all` on specific tags in the lookup by passing in the `includeTags` or `excludeTags` option. fixes #72
- Loading branch information
George Adams
committed
Feb 28, 2017
1 parent
1820757
commit 96b056a
Showing
8 changed files
with
449 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
const _ = require('lodash'); | ||
|
||
function checkTags(options, mod, name, log) { | ||
// Returns true if the module should be skipped. | ||
|
||
if ((options.excludeTags.length && !options.includeTags.length && !mod.tags) | ||
|| (!options.includeTags.length && !options.excludeTags.length)) { | ||
return false; // No checks to run. | ||
} else if (options.includeTags.length && !options.excludeTags.length | ||
&& !mod.tags) { | ||
return true; // No tags for this module. | ||
} | ||
|
||
if (typeof mod.tags === 'string') { | ||
mod.tags = [mod.tags]; // If mod.tags is a single string, convert to array. | ||
} | ||
|
||
let excludeTagMatches = _.intersection(options.excludeTags, mod.tags); | ||
|
||
if (excludeTagMatches.length) { | ||
log.info(name, | ||
`skipped as these excludeTags matched: ${excludeTagMatches}`); | ||
return true; // We matched an excludeTag. | ||
} | ||
|
||
let includeTagMatches = _.intersection(options.includeTags, mod.tags); | ||
|
||
if (includeTagMatches.length) { | ||
log.info(name, | ||
`will run as these includeTags matched: ${includeTagMatches}`); | ||
return false; // We matched an includeTag. | ||
} | ||
|
||
if (options.includeTags.length) { | ||
log.info(`${name} skipped as no includeTags matched`); | ||
return true; // We did not match an includeTag. | ||
} else { | ||
log.info(`${name} will run as no excludeTags matched`); | ||
return false; // We did not match an excludeTag. | ||
} | ||
|
||
} | ||
|
||
module.exports = checkTags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"omg-i-pass": { | ||
"npm": true, | ||
"tags": "tag1" | ||
}, | ||
"omg-i-fail": { | ||
"npm": true, | ||
"tags": ["tag2", "tagNotUsed"] | ||
}, | ||
"omg-i-pass-too": { | ||
"npm": true | ||
} | ||
} |
Oops, something went wrong.