debian-mirror-gitlab/danger/duplicate_yarn_dependencies/Dangerfile
2019-02-15 15:39:39 +05:30

27 lines
711 B
Ruby

# frozen_string_literal: true
return unless helper.all_changed_files.include? 'yarn.lock'
duplicate = `node_modules/.bin/yarn-deduplicate --list --strategy fewer yarn.lock`
.split(/$/)
.map(&:strip)
.reject(&:empty?)
return if duplicate.empty?
warn 'This merge request has introduced duplicated yarn dependencies.'
markdown(<<~MARKDOWN)
## Duplicate yarn dependencies
The following dependencies should be de-duplicated:
* #{duplicate.map { |path| "`#{path}`" }.join("\n* ")}
Please run the following command and commit the changes to `yarn.lock`:
```
node_modules/.bin/yarn-deduplicate --strategy fewer yarn.lock \\
&& yarn install
```
MARKDOWN