Skip to content

Commit b3e7dd1

Browse files
committed
fix(diff): set option where for pacote
pacote expects a **where** option that sets the cwd for all its operations, ref: https://github.com/npm/pacote#options This change properly sets that option in libnpmdiff options that will then properly forward it to pacote, this is specially important for when reading local file system specs. PR-URL: #2822 Credit: @ruyadorno Close: #2822 Reviewed-by: @wraithgar
1 parent 5d92239 commit b3e7dd1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/diff.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ class Diff {
5050
const [a, b] = await this.retrieveSpecs(specs)
5151
npmlog.info('diff', { src: a, dst: b })
5252

53-
const res = await libdiff(
54-
[a, b],
55-
{ ...this.npm.flatOptions, diffFiles: args }
56-
)
53+
const res = await libdiff([a, b], {
54+
...this.npm.flatOptions,
55+
diffFiles: args,
56+
where: this.where,
57+
})
5758
return output(res)
5859
}
5960

test/lib/diff.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,13 @@ t.test('first arg is a valid semver range', t => {
951951

952952
t.test('first arg is an unknown dependency name', t => {
953953
t.test('second arg is a qualified spec', t => {
954-
t.plan(3)
954+
t.plan(4)
955955

956956
libnpmdiff = async ([a, b], opts) => {
957957
t.equal(a, 'bar@latest', 'should set expected first spec')
958958
t.equal(b, 'bar@2.0.0', 'should set expected second spec')
959959
t.match(opts, npm.flatOptions, 'should forward flat options')
960+
t.match(opts, { where: '.' }, 'should forward pacote options')
960961
}
961962

962963
npm.flatOptions.diff = ['bar', 'bar@2.0.0']

0 commit comments

Comments
 (0)