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

Support for windows platform #42

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/dbDump.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function dbDump(config, output_paths, noExec) {
}
});

cmd = tpl_ssh + " \\ " + tpl_mysqldump;
cmd = tpl_ssh + " " + tpl_mysqldump;
}

if (!noExec) {
Expand Down
18 changes: 7 additions & 11 deletions lib/dbReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,24 @@ function dbReplace(search, replace, output_path, noExec) {
// avoids overwriting original backup
grunt.file.copy(output_path.file, output_path["file-tmp"]);

// Perform Search and replace on the temp file (not original)
var cmd = grunt.template.process( tpls.search_replace, {
data: {
search: search,
replace: replace,
path: output_path["file-tmp"]
}
});

if ( grunt.file.exists(output_path["file-tmp"])) {
// Execute cmd
if (!noExec) {
grunt.log.writeln("Replacing '" + search + "' with '" + replace + "' in the export (.sql) path.file.");
shell.exec(cmd);

var reg= new RegExp(search,"g"); //Create a global regexp w/ search string
var myFile=grunt.file.read(output_path["file-tmp"]); //Get file as a string
var result = myFile.replace(reg, replace); //Replace search string by replace string
grunt.file.write(output_path["file-tmp"], result); //Write in file

grunt.log.oklns("Database references succesfully updated.");
}
} else {
grunt.fail.warn("Search & Replace was unable to locate database dump .sql file (expected at: " + output_path.file + ").", 6);
}

// Return for reference and test suite purposes
return cmd;
return shell;
}

module.exports = dbReplace;
2 changes: 0 additions & 2 deletions lib/tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
var tpls = {

search_replace: "sed -i '' 's#<%= search %>#<%= replace %>#g' <%= path %>",

backup_path: "<%= backups_dir %>/<%= env %>/<%= date %>/<%= time %>",

mysql: "mysql -h <%= host %> -u <%= user %> -p<%= pass %> -P<%= port %> <%= database %>",
Expand Down
2 changes: 1 addition & 1 deletion tasks/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = function(grunt) {
dbDump(local_options, local_backup_paths);

// Search and Replace database refs
dbReplace( local_options.url, target_options.url, local_backup_paths.file );
dbReplace( local_options.url, target_options.url, local_backup_paths );

// Dump target DB
dbDump(target_options, target_backup_paths);
Expand Down