Convert unibuilds on download instead of on load

This commit is contained in:
Sashko Stubailo
2015-01-16 10:18:12 -08:00
parent 42fe815e0f
commit 8788b39b54
2 changed files with 20 additions and 1 deletions

View File

@@ -670,7 +670,7 @@ _.extend(Isopack.prototype, {
var unibuildJson = JSON.parse(
files.readFile(files.pathJoin(dir, unibuildMeta.path)));
unibuildJson = colonConverter.convertUnibuild(unibuildJson);
var unibuildBasePath =
files.pathDirname(files.pathJoin(dir, unibuildMeta.path));

View File

@@ -219,6 +219,25 @@ _.extend(exports.Tropohouse.prototype, {
// Result: Now we are in a state where the isopack.json file paths are
// consistent with the paths in the downloaded tarball.
// Now, we have to convert the unibuild files in the same way.
_.each(metadata.builds, function (unibuildMeta) {
var unibuildJsonPath = files.pathJoin(dir, unibuildMeta.path);
var unibuildJson = JSON.parse(files.readFile(unibuildJsonPath));
if (unibuildJson.format !== "unipackage-unibuild-pre1") {
throw new Error("Unsupported isopack unibuild format: " +
JSON.stringify(unibuildJson.format));
}
var convertedUnibuild = colonConverter.convertUnibuild(unibuildJson);
files.writeFile(convertedUnibuild,
new Buffer(JSON.stringify(unibuildJson, null, 2), 'utf8'),
{mode: 0444});
// Result: Now we are in a state where the unibuild file paths are
// consistent with the paths in the downloaded tarball.
});
}
return targetDirectory;