porsager / wright

🚀 Work Fast Work Wright
Do What The F*ck You Want To Public License
180 stars 15 forks source link

Wright fails if packages are deduped #28

Closed tivac closed 6 years ago

tivac commented 6 years ago

I'm trying to run wright in an environment where there are a lot of NPM packages installed. It looks like something else I'm using depends on the pws package, because my directory ends up looking like this.

./node_modules
    ...
    ./pws
    ...
    ./wright
        ...
       ./node_modules
            ...

without a pws dir inside of ./node_modules/wright/node_modules.

This would normally be fine given node's package resolution semantics, but this line breaks things:

https://github.com/porsager/wright/blob/7efa2909a94c17cf6f82eee48af1283d7aa99572/lib/serve.js#L219

This can be fixed by replacing the line with

const pws = fs.readFileSync(require.resolve('pws/index.js'), 'utf8')

So that it is more resilient to npm's deduping.

porsager commented 6 years ago

Ah, thanks a lot Pat, that's much better!!