Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion run-if-changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ if (changedFiles.length === 0) {
process.exit(0);
}

require('./src/runForMatchingPatterns')(changedFiles, config);
const resolveMatchingPatterns = require('./src/resolveMatchingPatterns');
const runCommands = require('./src/runCommands');

runCommands(resolveMatchingPatterns(changedFiles, config));
2 changes: 2 additions & 0 deletions src/findBinary.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This code is adapted from https://git.io/fhsKi

const parseStringArgv = require('string-argv');
const which = require('npm-which')(process.cwd());

Expand Down
13 changes: 13 additions & 0 deletions src/resolveMatchingPatterns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const matcher = require('./matcher');

module.exports = function resolveMatchingPatterns(list, config) {
const commandsToRun = Object.entries(config)
.filter(([pattern]) => matcher(list, [pattern]))
.map(([, commands]) => commands)
// Flatten array
.reduce((acc, val) => acc.concat(val), []);

// unique commands, do not run them multiple times if they are the same
// for multiple patterns or they are repeated in a list for a single pattern
return [...new Set(commandsToRun)];
};
8 changes: 0 additions & 8 deletions src/runForMatchingPatterns.js

This file was deleted.