nfour / serverless-build-plugin

A Node.js focused build plugin for serverless.
MIT License
41 stars 9 forks source link

Corrected creation of relative path names in artifact #22

Closed arabold closed 7 years ago

arabold commented 7 years ago

This fixes issue #21.

Code Changes

filePath.split(relativePath)[1] cannot be used for paths that look something like this: /Users/arabold/Documents/myProject/node_modules/redis/node_modules/redis-commands/test/index.js.

The relativePath in this case is node_modules/redis which results in a wrong split of the file path and thus causes a broken ZIP files as the paths get mangled.

This PR fixes this problem by properly extracting the relPath as a substring.

You might want to check the implementation of the directory handling, too. Not sure if this will have a similar issue, too.

nfour commented 7 years ago

Nice catch. Splitting was clearly a bit shortsighted.

I'll review this asap.