upload_to_mega.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. var util = require('util');
  2. var exec = require('child_process').exec;
  3. var sanitize = require("sanitize-filename");
  4. var email = process.env.MEGA_EMAIL;
  5. var password = process.env.MEGA_PASSWORD;
  6. var sourceFileName = 'build.7z';
  7. var dstFileName = process.env.APPVEYOR_REPO_COMMIT.substring(0, 8) + " - " +
  8. process.env.APPVEYOR_REPO_COMMIT_MESSAGE.substring(0, 100) + ".7z";
  9. dstFileName = sanitize(dstFileName);
  10. var cmd = util.format('megaput ../%s --path \"/Root/Citra/Windows/%s\" --username=%s --password=%s --no-progress',
  11. sourceFileName,
  12. dstFileName,
  13. email,
  14. password);
  15. // only upload build on master branch, and not on other branches or PRs
  16. if (process.env.APPVEYOR_REPO_BRANCH == "master") {
  17. console.log("Uploading file " + dstFileName + " to Mega...");
  18. exec(cmd, function(error, stdout, stderr) {
  19. console.log('stdout: ' + stdout);
  20. console.log('stderr: ' + stderr);
  21. if (error !== null) {
  22. console.log('exec error: ' + error);
  23. }
  24. });
  25. }