Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] keeping original whole or partial stats #35

Open
jskrzypek opened this issue Apr 19, 2016 · 11 comments
Open

[Feature] keeping original whole or partial stats #35

jskrzypek opened this issue Apr 19, 2016 · 11 comments

Comments

@jskrzypek
Copy link

We have cordova hooks in our source folder (see the cordova hooks guide for more info: https://cordova.apache.org/docs/en/dev/guide/appdev/hooks/) that need to be copied into our destination folder and need to preserve the executable bit on their file mode (i.e. ls -l should print -rwxr-xr-x for these files).

Currently this doesn't happen, but it seems like it should be easy to do by passing a options object as a 3rd parameter to the to the fs.writeFileAsync() call in the writeFilePromises with the stat.mode from the fs.statAsync() call.

@jskrzypek
Copy link
Author

I'm trying to implement this on my fork, but it doesn't seem to be working.

I'm happy to make the PR but I need a bit of guidance.

@kevlened
Copy link
Contributor

The difficulty is in how we copy the files. By default, we add the files by adding them to compilation.assets and letting webpack take care of writing the files. The only time we write files with fs.writeFileAsync() is when a devServer is used (due to limitations of the server).

It's possible that this feature could piggyback on the additions needed for #15. That feature also requires fs.writeFileAsync for every file.

@davepuchyr
Copy link

@evilebottnawi This issue is a bug on linux and macOS, ie 2 out of 3 major operating systems. It would be nice if you recognized @michael-ciniawsky 's tags and this issue's importance. Node can't spawn()/exec()/etc a copied file while this bug exists.

@alexander-akait
Copy link
Member

@davepuchyr it is require to do PR in webpack-sources, by default webpack can not works with permissions

@davepuchyr
Copy link

Thanks for enlightening me and for the plugin.

@michael-ciniawsky
Copy link
Member

Maybe something in the direction of #119 would be sufficient enough/in the meantime

@socialcode-rob1
Copy link

To work around the issue, I've implemented this plugin https://github.com/GeKorm/webpack-permissions-plugin

It executes during the 'done' phase in the webpack lifecycle.

@alexander-akait alexander-akait changed the title [Bug] Plugin is not copying file modes with execute permissions [Feature] Plugin is not copying file modes with execute permissions Feb 15, 2019
@alexander-akait alexander-akait changed the title [Feature] Plugin is not copying file modes with execute permissions [Feature] Copy file permissions Feb 18, 2019
@marco-a
Copy link

marco-a commented May 18, 2019

Please make this happen. Great plugin but a pain in the ass to set the permissions afterwards ...

@alexander-akait alexander-akait changed the title [Feature] Copy file permissions [Feature] keeping original stats Aug 31, 2020
@alexander-akait alexander-akait changed the title [Feature] keeping original stats [Feature] keeping original stats () Aug 31, 2020
@alexander-akait alexander-akait changed the title [Feature] keeping original stats () [Feature] keeping original stats or partials Aug 31, 2020
@alexander-akait alexander-akait changed the title [Feature] keeping original stats or partials [Feature] keeping original whole stats or partial Aug 31, 2020
@alexander-akait alexander-akait changed the title [Feature] keeping original whole stats or partial [Feature] keeping original whole or partial stats Aug 31, 2020
@benze
Copy link

benze commented Oct 1, 2020

To work around the issue, I've implemented this plugin https://github.com/GeKorm/webpack-permissions-plugin

It executes during the 'done' phase in the webpack lifecycle.

@socialcode-rob1 How did you get the two to work in tandem? I've tried the webpack-permissions-plugin but it always seems to fire before the copy-webpack-plugin. I'm trying to get the webpack-permissions-plugin to fire after the copy-webpack-plugin has run such that the permissions are updated on the target files.

@ianpogi5
Copy link

Should this not be the default behavior of any copy functionality?

@MatthewLamperski
Copy link

If anyone is still having this issue, like I was. I was able to create a very small plugin like this:

const CopyPlugin = require('copy-webpack-plugin');
const chmodr = require('chmodr')
const path = require("path");

class PermissionsPlugin {
  apply(compiler) {
    compiler.hooks.afterEmit.tap("PermissionsPlugin", () => {
      console.log("changing permissions", path.join(__dirname, './path/to/files'), __dirname)
      chmodr(path.join(__dirname, './path/to/files'), 0o755, err => {
        console.log("Error changing perms " + err)
      })
    })
  }
}

This will fire after all assets are copied over, and is working well for me. You also have to add it into your plugins like so:

module.exports = {
  /* ... */
  plugins: [
    new PermissionsPlugin(),
    new CopyPlugin({
      options: {},
      /* ... */
    })
  ]
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.