grunt-deployments icon indicating copy to clipboard operation
grunt-deployments copied to clipboard

Make it work for windows platform

Open wizioo opened this issue 11 years ago • 8 comments

I have a Windows 8.1 with Wamp locally and I work with a remote linux platform. Your grunt plugin is fantastic but it didn't worked for me until I made some changes which can interest you.

To make it work on Win platform, there is 2 problem:

  1. Sed doesn't work on Windows platform. As shelljs is a dependencie, you can use:

        //Execute SED
        shell.sed("-i", search, replace, output_file);
    

    to replace:

    
         var cmd = grunt.template.process(tpls.search_replace, {
             data: {
                 search: search,
                 replace: replace,
                 path: output_file
             }
         });
    .....
        // Execute cmd
         shell.exec(cmd);
    

    in db_replace function and you don't need search_replace template either.

  2. Problem w/ command backslashes in db_dump function

    cmd = tpl_ssh + " \\ " + tpl_mysqldump;
    

    I just had to remove it (\\ ) to make it work for me. If not, mysql_dump is not launched. I don't know if it's crucial for other platforms.

wizioo avatar Mar 11 '14 10:03 wizioo

Hi @wizioo. Thanks for bringing this to my attention.

As I'm not based on a windows platform I'd really appreciate it if you were able to raise a pull request (into the develop branch) detailing these changes.

I can then easily inspect the diff and see if it's possible to provide a mechanism to allow the tool to be more configurable to function across multiple environments without the need to amend the core script.

Would that be possible?

getdave avatar Mar 11 '14 15:03 getdave

Hello @getdave. Thanks for your interest in my idea. I'll try to do it this week for sure.

wizioo avatar Mar 12 '14 07:03 wizioo

@wizioo Thanks for this, saved me a lot of time on Win7!

Also, +1 for Windows support. :)

nickbouton avatar Mar 15 '14 02:03 nickbouton

If using sed for search/replace, does it handle data in serialised arrays?

I'm thinking WordPress databases for example, which use serialised arrays.

davemac avatar Apr 29 '14 12:04 davemac

@davemac No I don't think sed will handle that. As far as I"m aware the only tool that does is the SearchReplaceDB PHP script I'm using on the advanced search replace branch of this repo.

If there's a node module that can handle this then that would be greatly preferable.

getdave avatar May 09 '14 11:05 getdave

@davemac Yeah, it doesn't work on serialised arrays... Any solution?

wizioo avatar May 22 '14 09:05 wizioo

Have a look at @webrain solution : https://github.com/webrain/grunt-wordpress-deploy Their search / replace function handle serialised arrays. Maybe we should use it to solve the problem.

wizioo avatar May 22 '14 11:05 wizioo

@wizioo The @webrain solution is a fork of my original. It would have been nice if they had contributed to my script rather than duplicate and rewrite but I understand if they prefer to work on their own solution. It's all open source after all! :)

I like the serialisation of arrays in their script. I suggest that we consider "borrowing" the serialization code and add a credit in a "history" section as they have on their script when referencing.

Any thoughts?

getdave avatar May 27 '14 13:05 getdave