Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(range): inherit options from input range #388

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions classes/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
options = parseOptions(options)

if (range instanceof Range) {
// inherit options
options = { loose: range.loose, includePrerelease: range.includePrerelease, ...range.options, ...options }

Check failure on line 8 in classes/range.js

View workflow job for this annotation

GitHub Actions / Lint

This line has a length of 112. Maximum allowed is 100
if (
range.loose === !!options.loose &&
range.includePrerelease === !!options.includePrerelease
Expand Down
2 changes: 2 additions & 0 deletions test/classes/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
const loose = new Range('1.2.3', { loose: true })
t.equal(new Range(loose, { loose: true }), loose, 'loose option')
t.equal(new Range(loose, true), loose, 'loose boolean')
t.not(new Range(loose), loose, 'created new range if not matched')

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 10.0.0

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 10.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 16.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 12.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 14.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 16.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 10.0.0

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 12.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 14.x

created new range if not matched

Check failure on line 50 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 10.x

created new range if not matched
t.notEqual(new Range(loose, { loose: false }), loose, 'created new range if not matched')
t.equal(new Range(loose), loose, 'inherit')

const incPre = new Range('1.2.3', { includePrerelease: true })
t.equal(new Range(incPre, { includePrerelease: true }), incPre,
'include prerelease, option match returns argument')
t.not(new Range(incPre), incPre,

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 10.0.0

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 10.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 16.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 12.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 14.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 16.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 10.0.0

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 12.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 14.x

include prerelease, option mismatch does not return argument

Check failure on line 57 in test/classes/range.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 10.x

include prerelease, option mismatch does not return argument
'include prerelease, option mismatch does not return argument')

t.end()
Expand Down