Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add offline mode #260

Merged
merged 8 commits into from Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/buildSystem.js
Expand Up @@ -20,6 +20,9 @@ function BuildSystem(options) {
this.options.runtime = this.options.runtime || appConfig.runtime;
this.options.runtimeVersion = this.options.runtimeVersion || appConfig.runtimeVersion;
this.options.arch = this.options.arch || appConfig.arch;
this.options.ensureInstalled = appConfig.ensureInstalled === undefined ? true : appConfig.ensureInstalled;
this.options.ensureDownloaded = appConfig.ensureDownloaded === undefined ? true : appConfig.ensureDownloaded;
this.options.customDownloadDir = this.options.customDownloadDir || appConfig.customDownloadDir;
}
}
this.log.verbose("CFG", "Build system options:");
Expand All @@ -32,7 +35,6 @@ function BuildSystem(options) {
BuildSystem.prototype._ensureInstalled = async function () {
try {
await this.toolset.initialize(true);
await this.dist.ensureDownloaded();
spjuanjoc marked this conversation as resolved.
Show resolved Hide resolved
}
catch (e) {
this._showError(e);
Expand All @@ -54,13 +56,19 @@ BuildSystem.prototype._showError = function (e) {
}
};

BuildSystem.prototype.install = function () {
return this._ensureInstalled();
BuildSystem.prototype.install = async function () {
await this._ensureInstalled();
await this.dist.ensureDownloaded();
};

BuildSystem.prototype._invokeCMake = async function (method) {
try {
await this._ensureInstalled();
spjuanjoc marked this conversation as resolved.
Show resolved Hide resolved
if (this.options.ensureInstalled === true) {
await this._ensureInstalled();
}
if (this.options.ensureDownloaded === true) {
await this.dist.ensureDownloaded();
}
return await this.cmake[method]();
}
catch (e) {
Expand Down
11 changes: 6 additions & 5 deletions lib/dist.js
Expand Up @@ -30,11 +30,12 @@ function Dist(options) {
Object.defineProperties(Dist.prototype, {
internalPath: {
get: function () {
return path.join(
environment.home,
".cmake-js",
(this.targetOptions.runtime) + "-" + this.targetOptions.arch,
"v" + this.targetOptions.runtimeVersion);
let mainDir = ".cmake-js";
spjuanjoc marked this conversation as resolved.
Show resolved Hide resolved
let runtimeArchDir = (this.targetOptions.runtime) + "-" + this.targetOptions.arch;
spjuanjoc marked this conversation as resolved.
Show resolved Hide resolved
let runtimeVersionDir = "v" + this.targetOptions.runtimeVersion;
spjuanjoc marked this conversation as resolved.
Show resolved Hide resolved
let downloadPath = this.options.customDownloadDir || path.join(mainDir, runtimeArchDir, runtimeVersionDir);

return path.join(environment.home, downloadPath);
}
},
externalPath: {
Expand Down