GeKorm / webpack-permissions-plugin

A webpack plugin to manage the permissions of output files and directories
MIT License
11 stars 8 forks source link

Update permissions only for existent files or directories. #2

Closed romankoval closed 5 years ago

romankoval commented 5 years ago

While building webpack individually 'done' event is triggered when first package is ready, but in case if wee need to update files included in different package the plugin fails that file doesn't exist.

Added verification if file exists before calling chmod operation.

GeKorm commented 5 years ago

Thanks a lot for the PR @romankoval ! I'll take a look within the week.

romankoval commented 5 years ago

Thanks @GeKorm.

Would be nice to get it in and build new version of npm as soon as possible, because I don't have possibility to deploy serverless project to AWS without right permissions.

GeKorm commented 5 years ago

@romankoval Do you have a simple reproduction of the issue so I can test this? I'm asking because Filehound is supposed to return files/directories that exist, so I'm having trouble understanding how fs.existsSync() helps the issue.

romankoval commented 5 years ago

@GeKorm actually I cannot share the whole code base, but in webpack config I have the following:

const PermissionsOutputPlugin = require('webpack-permissions-plugin');
...
new PermissionsOutputPlugin({
      buildFiles: [
        {
          path: path.join(__dirname, '.webpack/transcoder/ffmpeg'),
          fileMode: '777',
        },
        {
          path: path.join(__dirname, '.webpack/transcoder/ffprobe'),
          fileMode: '777',
        },
      ],
    }),

transcoder is a separate module that is build as part on serverless framework. There are plenty of separate lambdas that is built individually into separate zip archives but all of them are in the same project. Such as I need ffmpeg only for one module, it's not present in any other modules. The plugin is called on 'done' action for each module and in case if webpacked module doesn't contain the file the plugin fails. fs.existsSync() check if file is not present by webpacked dir 'webpack/...' than chmod is not executed on this path.

GeKorm commented 5 years ago

Hi @romankoval I published this as @v1.0.2-beta.0 (or @­beta) please let me know if it solves your issue.

romankoval commented 5 years ago

@GeKorm It works perfectly.

Thank you!

will you deploy stable version?

GeKorm commented 5 years ago

@romankoval No, thank you!
So I would like to leave the beta up for at least a week before deploying as a stable version. This change is low risk, but you never know with so many complex build processes out there 😄