-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support auto fix bug version of package (#256)
use `--fix-bug-versions` to enable this feature.
- Loading branch information
Showing
5 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use strict'; | ||
|
||
const coffee = require('coffee'); | ||
const rimraf = require('rimraf'); | ||
const mkdirp = require('mkdirp'); | ||
const path = require('path'); | ||
|
||
describe('fix-bug-versions.test.js', () => { | ||
const tmp = path.join(__dirname, 'fixtures', 'tmp'); | ||
const demo = path.join(__dirname, 'fixtures', 'fix-bug-versions-app'); | ||
const bin = path.join(__dirname, '../bin/install.js'); | ||
const update = path.join(__dirname, '../bin/update.js'); | ||
|
||
function cleanup() { | ||
rimraf.sync(tmp); | ||
rimraf.sync(path.join(demo, 'node_modules')); | ||
} | ||
|
||
beforeEach(() => { | ||
cleanup(); | ||
mkdirp.sync(tmp); | ||
}); | ||
afterEach(cleanup); | ||
|
||
it('should use fix version instead', done => { | ||
coffee.fork(bin, [ | ||
'is-my-json-valid@2.17.0', | ||
'-d', | ||
'--fix-bug-versions', | ||
'--no-cache', | ||
], { cwd: tmp }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /is-my-json-valid@2\.17\.1@is-my-json-valid/) | ||
.end(done); | ||
}); | ||
|
||
it('should support on install and update', function* () { | ||
yield coffee.fork(bin, [ | ||
'-d', | ||
'--fix-bug-versions', | ||
'--no-cache', | ||
], { cwd: demo }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /is-my-json-valid@2\.17\.1@is-my-json-valid/) | ||
.end(); | ||
|
||
yield coffee.fork(update, [ | ||
'-d', | ||
'--fix-bug-versions', | ||
'--no-cache', | ||
], { cwd: demo }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /is-my-json-valid@2\.17\.1@is-my-json-valid/) | ||
.end(); | ||
}); | ||
|
||
it('should not match version', done => { | ||
coffee.fork(bin, [ | ||
'is-my-json-valid@2.16.0', | ||
'-d', | ||
'--fix-bug-versions', | ||
'--no-cache', | ||
], { cwd: tmp }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /is-my-json-valid@2\.16\.0@is-my-json-valid/) | ||
.end(done); | ||
}); | ||
|
||
it('should not match name', done => { | ||
coffee.fork(bin, [ | ||
'mm', | ||
'-d', | ||
'--fix-bug-versions', | ||
'--no-cache', | ||
], { cwd: tmp }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /mm@\* installed/) | ||
.end(done); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "fix-bug-versions-app", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"is-my-json-valid": "2.17.0" | ||
} | ||
} |