Closed etamponi closed 6 years ago
In one node_modules, installation can be done only with --shamefully-flatten
or w/o it, otherwise, the node_modules structure will be a mess. I suggest, as with the --independent-leaves
flag, saving a property in node_modules/.modules.yaml
and failing installation if the config differs:
see https://github.com/pnpm/supi/blob/master/src/api/getContext.ts#L57-L64
Yes, I was thinking about it too, I agree
Il 20 feb 2018 21:23, "Zoltan Kochan" notifications@github.com ha scritto:
In one node_modules, installation can be done only with --shamefully-flatten or w/o it, otherwise, the node_modules structure will be a mess. I suggest, as with the --independeny-leaves flag, saving a property in node_modules/.modules.yaml and failing installation if the config differs:
see https://github.com/pnpm/supi/blob/master/src/api/getContext.ts#L57-L64
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pnpm/supi/pull/42#issuecomment-367104534, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjUNHtGEC3FXA7sPyGfKNiFt1Z-Rkt_ks5tWyd7gaJpZM4SLyFS .
copy these tests for --shamefully-flatten
:
test('--independent-leaves throws exception when executed on node_modules installed w/o the option',
test('--no-independent-leaves throws exception when executed on node_modules installed with --independent-leaves'
the new tests fail on Windows for some reason
This code does not do anything if
shamefullyFlatten
is set to false.The algorithm is simple:
1) during install, take the flattened tree, and symlink to node_modules every package that does not conflict with the root dependencies nor with previously "flattened" packages.
2) during uninstall, for each orphan, check if there is a symlink in node_modules that points to it, and remove it.
UPDATE:
3) after uninstall and general install, reflatten the remaining packages in case the operation freed some names in the root node_modules.