main.js 809 B

12345678910111213141516171819202122232425262728293031
  1. (function() {
  2. var callMksnapshot, getPathOfMksnapshot, mksnapshot, stripVersion;
  3. callMksnapshot = require('./mksnapshot-call');
  4. getPathOfMksnapshot = require('./mksnapshot-path');
  5. stripVersion = function(version) {
  6. var versions;
  7. if (version[0] === 'v') {
  8. version = version.substr(1);
  9. }
  10. versions = version.split('.');
  11. versions[2] = '0';
  12. return versions.join('.');
  13. };
  14. mksnapshot = function(content, target, version, arch, builddir, callback) {
  15. version = stripVersion(version);
  16. return getPathOfMksnapshot(version, arch, builddir, function(error, mksnapshot) {
  17. if (error) {
  18. return callback(error);
  19. }
  20. return callMksnapshot(mksnapshot, content, target, builddir, callback);
  21. });
  22. };
  23. module.exports = mksnapshot;
  24. }).call(this);