From 8f40078ee0cce3c50b7cd2308b9e03cad0d4b8c1 Mon Sep 17 00:00:00 2001 From: Artem Vasiliev Date: Wed, 25 Oct 2017 15:23:19 +0300 Subject: [PATCH] feat: allow 'pretest' to be custom command, too --- README.md | 15 +++++++++++++-- src/dont-break.js | 9 ++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 855a9be..0b69594 100644 --- a/README.md +++ b/README.md @@ -140,13 +140,24 @@ was working before the update. If this sounds excessive to you you can disable i "name": "foo-module-name", "test": "grunt test", "pretest": false - }, - "bar-name" + } ] ``` Here "foo-module-name" module will be tested only once, and "bar-name" twise: first with its published version of current module, and then with the updated version. +The "pretest" property can also accept custom script to run for pretesting: +``` +[ + { + "name": "foo-module-name", + "test": "grunt test", + "pretest": "grunt test && ./ci/after-pretesting-by-dont-break" + } +] +``` +By default it equals to "test" command. + ### Post-install command Before testing the dependent package dont-break installs its dev dependencies via `npm install` command run from the diff --git a/src/dont-break.js b/src/dont-break.js index 5b4bef8..b29a009 100644 --- a/src/dont-break.js +++ b/src/dont-break.js @@ -284,9 +284,16 @@ function testDependent (options, dependent) { }) if (testWithPreviousVersion) { + var modulePretestCommand + if (check.type('string', testWithPreviousVersion)) { + modulePretestCommand = testWithPreviousVersion + } else { + modulePretestCommand = moduleTestCommand + } + var pretestModuleInFolder = _.partial(testInFolder, modulePretestCommand) res = res .then(postInstallModuleInFolder) - .then(testModuleInFolder) + .then(pretestModuleInFolder) } return res