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