File tree Expand file tree Collapse file tree 4 files changed +45
-3
lines changed
pkg-tests-fixtures/packages/one-dep-scripted-1.0.0 Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 1+ /* @flow */
2+
3+ module . exports = require ( `./package.json` ) ;
4+
5+ for ( const key of [ `dependencies` , `devDependencies` , `peerDependencies` ] ) {
6+ for ( const dep of Object . keys ( module . exports [ key ] || { } ) ) {
7+ // $FlowFixMe The whole point of this file is to be dynamic
8+ module . exports [ key ] [ dep ] = require ( dep ) ;
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " one-dep-scripted" ,
3+ "version" : " 1.0.0" ,
4+ "dependencies" : {
5+ "has-bin-entries" : " 1.0.0"
6+ },
7+ "scripts" : {
8+ "install" : " has-bin-entries"
9+ }
10+ }
Original file line number Diff line number Diff line change @@ -203,5 +203,17 @@ module.exports = (makeTemporaryEnv: PackageDriver) => {
203203 ] ) ;
204204 } ) ,
205205 ) ;
206+
207+ test (
208+ `it should allow dependencies with install scripts to run the binaries exposed by their own dependencies` ,
209+ makeTemporaryEnv (
210+ {
211+ dependencies : { [ `one-dep-scripted` ] : `1.0.0` } ,
212+ } ,
213+ async ( { path, run, source} ) => {
214+ await run ( `install` ) ;
215+ } ,
216+ ) ,
217+ ) ;
206218 } ) ;
207219} ;
Original file line number Diff line number Diff line change @@ -203,11 +203,21 @@ export async function makeEnv(
203203 }
204204 }
205205
206- const pnpFile = `${ config . lockfileFolder } /${ constants . PNP_FILENAME } ` ;
207- if ( await fs . exists ( pnpFile ) ) {
206+ let pnpFile ;
207+
208+ if ( process . versions . pnp ) {
209+ pnpFile = dynamicRequire . resolve ( 'pnpapi' ) ;
210+ } else {
211+ const candidate = `${ config . lockfileFolder } /${ constants . PNP_FILENAME } ` ;
212+ if ( await fs . exists ( candidate ) ) {
213+ pnpFile = candidate ;
214+ }
215+ }
216+
217+ if ( pnpFile ) {
208218 const pnpApi = dynamicRequire ( pnpFile ) ;
209219
210- const packageLocator = pnpApi . findPackageLocator ( `${ config . cwd } /` ) ;
220+ const packageLocator = pnpApi . findPackageLocator ( `${ cwd } /` ) ;
211221 const packageInformation = pnpApi . getPackageInformation ( packageLocator ) ;
212222
213223 for ( const [ name , reference ] of packageInformation . packageDependencies . entries ( ) ) {
You can’t perform that action at this time.
0 commit comments