diff --git a/tools/catalog.js b/tools/catalog.js index c4005c0e9f..012386ea77 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -609,6 +609,9 @@ _.extend(CompleteCatalog.prototype, { // And put a build record for it in the catalog var versionId = self.getLatestVersion(name); + packageCache.packageCache.cachePackageAtPath( + name, sourcePath, unipackage); + self.builds.push({ packageName: name, architecture: unipackage.architectures().join('+'), @@ -618,11 +621,6 @@ _.extend(CompleteCatalog.prototype, { lastUpdated: null, buildPublished: null }); - - // XXX XXX maybe you actually want to, like, save the unipackage - // in memory into a cache? rather than leaving packageCache to - // reload it? or maybe packageCache is unified into catalog - // somehow? sleep on it }, // Add a local package to the catalog. `name` is the name to use for // the package and `directory` is the directory that contains the diff --git a/tools/package-cache.js b/tools/package-cache.js index 8c899d1afb..196d7bd15f 100644 --- a/tools/package-cache.js +++ b/tools/package-cache.js @@ -44,6 +44,19 @@ _.extend(PackageCache.prototype, { self.loadedPackages = {}; }, + + cachePackageAtPath : function (name, loadPath, unipackage) { + var self = this; + var key = name + "@" + loadPath; + var buildDir = path.join(loadPath, '.build.'+ name); + + self.loadedPackages[key] = { + pkg: unipackage, + sourceDir: loadPath, + buildDir: buildDir + }; + }, + // Given a path to a package on disk, retrieve a Package // object. // @@ -90,7 +103,7 @@ _.extend(PackageCache.prototype, { } if (isUpToDate) { - // Cache hit + // Cache it self.loadedPackages[key] = entry; return entry.pkg; } @@ -121,7 +134,7 @@ _.extend(PackageCache.prototype, { if (fs.existsSync(buildDir)) { unipackage = new Unipackage.Unipackage; unipackage.initFromPath(name, buildDir); - if (compiler.checkUpToDate(packageSource, unipackage)) { + if (compiler.checkUpToDate(packageSource, unipackage)) { self.loadedPackages[key] = { pkg: unipackage, sourceDir: loadPath, buildDir: buildDir @@ -179,6 +192,7 @@ _.extend(PackageCache.prototype, { packageSource.initFromAppDir(appDir, ignoreFiles); return compiler.compile(packageSource).unipackage; } + }); packageCache.packageCache = new PackageCache;