Skip to content

Commit

Permalink
tested against lodash library and check-more-types, fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 31, 2014
1 parent 5fe6f19 commit a03d634
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 1 addition & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ function testDependent(dependent) {

function testDependents(dependents) {
la(check.array(dependents), dependents);
// var testers = dependents.map(testDependent);
// return testers.reduce(q.when, q(true));
return dependents.reduce(function (prev, dependent) {
return prev.then(function () {
return testDependent(dependent);
Expand All @@ -119,17 +117,8 @@ function dontBreak() {
console.log('PASS: Current version does not break dependents');
}, function (err) {
console.log('FAIL: Current version break dependents');
console.error(err.message);
err && err.message && console.error(err.message);
}).done();
}

dontBreak();

// testDependent('dont-break-foo-user').done();
/*
.then(function (folder) {
la(check.unemptyString(folder), 'expected install folder', folder);
la(fs.existsSync(folder), 'cannot find install folder', folder);
console.log('installed into folder', folder);
}).done();
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dont-break",
"version": "0.0.1",
"version": "0.0.2",
"description": "Checks if current version of your package would break dependent projects",
"main": "index.js",
"scripts": {
Expand Down

2 comments on commit a03d634

@bahmutov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example: checking if new release of lodash would break check-more-types

step 1 - try current latest version of lodash

Clone lodash, create .dont-break file echo check-more-types > .dont-break

step 2 - confirm the current version still work

check-more-types depends on lodash@2.4.1 First let us confirm that the current source @3.0.0-pre still works

~/git/lodash on master
$ dont-break
dependents [ 'check-more-types' ]
testing check-more-types
  installing check-more-types
installed into /tmp/lodash@3.0.0-pre-against-check-more-types
installing dev dependencies /tmp/lodash@3.0.0-pre-against-check-more-types/lib/node_modules/check-more-types
  NPM install in current folder
restoring current directory /Users/gleb/git/lodash
  npm test
tests work in /tmp/lodash@3.0.0-pre-against-check-more-types/lib/node_modules/check-more-types
copied /Users/gleb/git/lodash/* to /tmp/lodash@3.0.0-pre-against-check-more-types/lib/node_modules/check-more-types/node_modules/lodash
  npm test
tests work in /tmp/lodash@3.0.0-pre-against-check-more-types/lib/node_modules/check-more-types
all dependents tested
PASS: Current version does not break dependents

step 3 - break a function in lodash

lodash is only used in check-more-types to run 1 test (partial right application)

./test/load-under-node-test.js:12:var _ = require('lodash');
./test/load-under-node-test.js:13:var hasFoo = _.partialRight(moreCheck.has, 'foo');

let us break _.partialRight by changing slice to start with third argument.

// dist/lodash.compat.js
function partialRight(func) {
  var args = slice(arguments, [-1),-]{+2),+}
      holders = replaceHolders(args, partialRight.placeholder);

  return basePartial(func, PARTIAL_RIGHT_FLAG, args, holders);
}

Run dont-break again

~/git/lodash on master*
$ dont-break
dependents [ 'check-more-types' ]
testing check-more-types
...
npm test returned 1
test errors:
AssertionError: false == true
    at Console.assert (console.js:102:23)
...
tests did not work in /tmp/lodash@3.0.0-pre-against-check-more-types/lib/node_modules/check-more-types
code 1
FAIL: Current version break dependents

Even if lodash's own unit test passed, we now detect that we would break a dependent project.

@jdalton
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So 🆒!

Related to npm/issues/6510.

Please sign in to comment.