summaryrefslogtreecommitdiff
path: root/danger
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-12-18 10:42:09 +0000
committerRémy Coutable <remy@rymai.me>2018-12-18 10:42:09 +0000
commit9e26728cfe9ebc2d3ba4330065ebb9eb966d4a8c (patch)
tree7222ff88f285e4813dc2bc1bb38fe36a0c866c2c /danger
parent7a143215c33c6746a0b6b35a8503b9fb918cb405 (diff)
parent8950e90a3f523a1851108dbb916816e3cf5e1a42 (diff)
downloadgitlab-ce-9e26728cfe9ebc2d3ba4330065ebb9eb966d4a8c.tar.gz
Merge branch '51226-check-yarn-lock' into 'master'
Add danger check for duplicate yarn dependencies Closes #51226 See merge request gitlab-org/gitlab-ce!21591
Diffstat (limited to 'danger')
-rw-r--r--danger/duplicate_yarn_dependencies/Dangerfile27
1 files changed, 27 insertions, 0 deletions
diff --git a/danger/duplicate_yarn_dependencies/Dangerfile b/danger/duplicate_yarn_dependencies/Dangerfile
new file mode 100644
index 00000000000..25f81ec86a4
--- /dev/null
+++ b/danger/duplicate_yarn_dependencies/Dangerfile
@@ -0,0 +1,27 @@
+# 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