debian-mirror-gitlab/danger/duplicate_yarn_dependencies/Dangerfile

30 lines
782 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
return unless helper.all_changed_files.include?('yarn.lock')
2019-02-15 15:39:39 +05:30
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.'
2019-12-04 20:38:33 +05:30
if GitlabDanger.new(helper.gitlab_helper).ci?
markdown(<<~MARKDOWN)
## Duplicate yarn dependencies
2019-02-15 15:39:39 +05:30
2019-12-04 20:38:33 +05:30
The following dependencies should be de-duplicated:
2019-02-15 15:39:39 +05:30
2019-12-04 20:38:33 +05:30
* #{duplicate.map { |path| "`#{path}`" }.join("\n* ")}
2019-02-15 15:39:39 +05:30
2019-12-04 20:38:33 +05:30
Please run the following command and commit the changes to `yarn.lock`:
2019-02-15 15:39:39 +05:30
2019-12-04 20:38:33 +05:30
```
node_modules/.bin/yarn-deduplicate --strategy fewer yarn.lock \\
&& yarn install
```
MARKDOWN
end