in lib/resolvers/PackageResolver.ts [20:59]
static resolve(version: string, cacheRoot: string): Promise<MaterialToolsPackage> {
if (version === 'latest') {
// Fetch the latest version remotely.
version = this._retrieveLatestVersion();
} else if (version === 'local') {
// Figure out the version, based on the node_modules.
version = this._retrieveLocalVersion();
}
// Run validators for the current version
this._validateVersion(version);
return this._isExisting(path.join(path.resolve(cacheRoot), version))
.then(this._resolveDirectories)
.then(directories => {
Logger.info('Using AngularJS Material version from cache.');
return {
root: path.join(directories.module, '..'),
module: directories.module,
source: directories.source,
version: version
};
})
.catch(directories => {
directories = this._resolveDirectories(directories);
return Promise.all([
VersionDownloader.getModuleVersion(version, directories.module),
VersionDownloader.getSourceVersion(version, directories.source)
]).then(downloadPaths => {
return {
root: path.join(directories.module, '..'),
module: downloadPaths[0],
source: downloadPaths[1],
version: version
};
});
});
}