@@ -88,7 +88,7 @@ t.test('--prefix', async t => {
88
88
t.ok(exists.isFile(), 'bin ran, creating file')
89
89
})
90
90
91
-
t.test('workspaces', async t => {
91
+
t.test('runs in workspace path', async t => {
92
92
const registry = new MockRegistry({
93
93
tap: t,
94
94
registry: 'https://registry.npmjs.org/',
@@ -124,12 +124,101 @@ t.test('workspaces', async t => {
124
124
await registry.package({ manifest,
125
125
tarballs: {
126
126
'1.0.0': path.join(npm.prefix, 'npm-exec-test'),
127
-
} })
127
+
},
128
+
})
128
129
await npm.exec('exec', ['@npmcli/npx-test'])
129
130
const exists = await fs.stat(path.join(npm.prefix, 'workspace-a', 'npm-exec-test-success'))
130
131
t.ok(exists.isFile(), 'bin ran, creating file inside workspace')
131
132
})
132
133
134
+
t.test('finds workspace bin first', async t => {
135
+
const { npm } = await loadMockNpm(t, {
136
+
config: {
137
+
workspace: ['workspace-a'],
138
+
},
139
+
prefixDir: {
140
+
'package.json': JSON.stringify({
141
+
name: '@npmcli/npx-workspace-root-test',
142
+
bin: { 'npx-test': 'index.js' },
143
+
workspaces: ['workspace-a'],
144
+
}),
145
+
'index.js': `#!/usr/bin/env node
146
+
require('fs').writeFileSync('npm-exec-test-fail', '')`,
147
+
'workspace-a': {
148
+
'package.json': JSON.stringify({
149
+
name: '@npmcli/npx-workspace-test',
150
+
bin: { 'npx-test': 'index.js' },
151
+
}),
152
+
'index.js': `#!/usr/bin/env node
153
+
require('fs').writeFileSync('npm-exec-test-success', '')`,
154
+
},
155
+
},
156
+
})
157
+
158
+
await npm.exec('install', []) // reify
159
+
await npm.exec('exec', ['npx-test'])
160
+
const exists = await fs.stat(path.join(npm.prefix, 'workspace-a', 'npm-exec-test-success'))
161
+
t.ok(exists.isFile(), 'bin ran, creating file inside workspace')
162
+
t.rejects(fs.stat(path.join(npm.prefix, 'npm-exec-test-fail')))
163
+
})
164
+
165
+
t.test('finds workspace dep first', async t => {
166
+
const registry = new MockRegistry({
167
+
tap: t,
168
+
registry: 'https://registry.npmjs.org/',
169
+
})
170
+
171
+
const manifest = registry.manifest({ name: '@npmcli/subdep', versions: ['1.0.0', '2.0.0'] })
172
+
manifest.versions['1.0.0'].bin = { 'npx-test': 'index.js' }
173
+
manifest.versions['2.0.0'].bin = { 'npx-test': 'index.js' }
174
+
175
+
const { npm } = await loadMockNpm(t, {
176
+
prefixDir: {
177
+
subdep: {
178
+
one: {
179
+
'package.json': JSON.stringify(manifest.versions['1.0.0']),
180
+
'index.js': `#!/usr/bin/env node
181
+
require('fs').writeFileSync('npm-exec-test-one', '')`,
182
+
},
183
+
two: {
184
+
'package.json': JSON.stringify(manifest.versions['2.0.0']),
185
+
'index.js': `#!/usr/bin/env node
186
+
require('fs').writeFileSync('npm-exec-test-two', '')`,
187
+
},
188
+
},
189
+
'package.json': JSON.stringify({
190
+
name: '@npmcli/npx-workspace-root-test',
191
+
dependencies: { '@npmcli/subdep': '1.0.0' },
192
+
bin: { 'npx-test': 'index.js' },
193
+
workspaces: ['workspace-a'],
194
+
}),
195
+
'index.js': `#!/usr/bin/env node
196
+
require('fs').writeFileSync('npm-exec-test-fail', '')`,
197
+
'workspace-a': {
198
+
'package.json': JSON.stringify({
199
+
name: '@npmcli/npx-workspace-test',
200
+
dependencies: { '@npmcli/subdep': '2.0.0' },
201
+
bin: { 'npx-test': 'index.js' },
202
+
}),
203
+
'index.js': `#!/usr/bin/env node
204
+
require('fs').writeFileSync('npm-exec-test-success', '')`,
205
+
},
206
+
},
207
+
})
208
+
209
+
await registry.package({ manifest,
210
+
tarballs: {
211
+
'1.0.0': path.join(npm.prefix, 'subdep', 'one'),
212
+
'2.0.0': path.join(npm.prefix, 'subdep', 'two'),
213
+
},
214
+
})
215
+
await npm.exec('install', [])
216
+
npm.config.set('workspace', ['workspace-a'])
217
+
await npm.exec('exec', ['npx-test'])
218
+
const exists = await fs.stat(path.join(npm.prefix, 'workspace-a', 'npm-exec-test-success'))
219
+
t.ok(exists.isFile(), 'bin ran, creating file')
220
+
})
221
+
133
222
t.test('npx --no-install @npmcli/npx-test', async t => {
134
223
const registry = new MockRegistry({
135
224
tap: t,
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4