Skip to content

Commit

Permalink
fix log output
Browse files Browse the repository at this point in the history
  • Loading branch information
lukka committed Apr 2, 2023
1 parent b31715b commit e3b09b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
14 changes: 8 additions & 6 deletions dist/index.js
Expand Up @@ -122,8 +122,9 @@ class VcpkgAction {
// Ensure vcpkg root is set.
if (!vcpkgRoot) {
vcpkgRoot = yield runvcpkglib.getDefaultVcpkgDirectory(this.baseUtilLib.baseLib);
baseLib.info(`The vcpkg's root directory is not provided, using the predefined: '${this.vcpkgRootDir}'`);
baseLib.info(`The vcpkg's root directory is not provided, using the default value: '${this.vcpkgRootDir}'`);
}
baseLib.info(`The vpckg root directory: '${vcpkgRoot}'`);
// Create the vcpkg_root and cache directory if needed.
const binCachePath = (_a = this.binaryCachePath) !== null && _a !== void 0 ? _a : yield runvcpkglib.getDefaultVcpkgCacheDirectory(this.baseUtilLib.baseLib);
baseLib.debug(`vcpkgRootDir=${this.vcpkgRootDir}, binCachePath=${binCachePath}`);
Expand All @@ -136,20 +137,21 @@ class VcpkgAction {
if (!this.vcpkgRootDir) {
throw new Error(`vcpkgRootDir is not defined!`);
}
let vcpkgJsonFilePath = null;
const vcpkgJsonPath = yield vcpkgutil.Utils.getVcpkgJsonPath(this.baseUtilLib, this.vcpkgJsonGlob, this.vcpkgJsonIgnores);
vcpkgJsonFilePath = yield this.getCurrentDirectoryForRunningVcpkg(vcpkgJsonPath);
const vcpkgJsonFilePath = yield this.baseUtilLib.wrapOp(`Searching for vcpkg.json with glob expression '${this.vcpkgJsonGlob}'`, () => __awaiter(this, void 0, void 0, function* () {
const vcpkgJsonPath = yield vcpkgutil.Utils.getVcpkgJsonPath(this.baseUtilLib, this.vcpkgJsonGlob, this.vcpkgJsonIgnores);
return yield this.getCurrentDirectoryForRunningVcpkg(vcpkgJsonPath);
}));
let isCacheHit = null;
let cacheKey = null;
if (this.doNotCache) {
this.baseUtilLib.baseLib.debug(`Skipping restoring vcpkg as caching is disabled. Set input 'doNotCache:false' to enable caching.`);
}
else {
cacheKey =
yield this.baseUtilLib.wrapOp('Compute vcpkg cache key', () => __awaiter(this, void 0, void 0, function* () {
yield this.baseUtilLib.wrapOp('Computing vcpkg cache key', () => __awaiter(this, void 0, void 0, function* () {
const keys = yield vcpkgutil.Utils.computeCacheKeys(this.baseUtilLib, this.vcpkgRootDir, // HACK: if it were not set it would have thrown before.
this.userProvidedCommitId);
if (keys && vcpkgJsonPath) {
if (keys) {
baseLib.info(`Computed key: ${JSON.stringify(keys)}`);
}
else {
Expand Down
18 changes: 10 additions & 8 deletions src/vcpkg-action.ts
Expand Up @@ -66,8 +66,9 @@ export class VcpkgAction {
// Ensure vcpkg root is set.
if (!vcpkgRoot) {
vcpkgRoot = await runvcpkglib.getDefaultVcpkgDirectory(this.baseUtilLib.baseLib);
baseLib.info(`The vcpkg's root directory is not provided, using the predefined: '${this.vcpkgRootDir}'`);
baseLib.info(`The vcpkg's root directory is not provided, using the default value: '${this.vcpkgRootDir}'`);
}
baseLib.info(`The vpckg root directory: '${vcpkgRoot}'`);

// Create the vcpkg_root and cache directory if needed.
const binCachePath: string = this.binaryCachePath ?? await runvcpkglib.getDefaultVcpkgCacheDirectory(this.baseUtilLib.baseLib);
Expand All @@ -77,32 +78,33 @@ export class VcpkgAction {

// Set the place where vcpkg is putting the binary caching artifacts.
this.baseUtilLib.baseLib.setVariable(VcpkgAction.VCPKG_DEFAULT_BINARY_CACHE, binCachePath);

return vcpkgRoot;
});

if (!this.vcpkgRootDir) {
throw new Error(`vcpkgRootDir is not defined!`);
}

let vcpkgJsonFilePath: string | null = null;
const vcpkgJsonPath = await vcpkgutil.Utils.getVcpkgJsonPath(
this.baseUtilLib, this.vcpkgJsonGlob, this.vcpkgJsonIgnores);
vcpkgJsonFilePath = await this.getCurrentDirectoryForRunningVcpkg(vcpkgJsonPath);
const vcpkgJsonFilePath: string | null =
await this.baseUtilLib.wrapOp(`Searching for vcpkg.json with glob expression '${this.vcpkgJsonGlob}'`, async () => {
const vcpkgJsonPath = await vcpkgutil.Utils.getVcpkgJsonPath(
this.baseUtilLib, this.vcpkgJsonGlob, this.vcpkgJsonIgnores);
return await this.getCurrentDirectoryForRunningVcpkg(vcpkgJsonPath);
});

let isCacheHit: boolean | null = null;
let cacheKey: baseutillib.KeySet | null = null;
if (this.doNotCache) {
this.baseUtilLib.baseLib.debug(`Skipping restoring vcpkg as caching is disabled. Set input 'doNotCache:false' to enable caching.`);
} else {
cacheKey =
await this.baseUtilLib.wrapOp('Compute vcpkg cache key', async () => {
await this.baseUtilLib.wrapOp('Computing vcpkg cache key', async () => {
const keys = await vcpkgutil.Utils.computeCacheKeys(
this.baseUtilLib,
this.vcpkgRootDir as string, // HACK: if it were not set it would have thrown before.
this.userProvidedCommitId);

if (keys && vcpkgJsonPath) {
if (keys) {
baseLib.info(`Computed key: ${JSON.stringify(keys)}`);
} else {
throw new Error("Computation for the cache key failed!");
Expand Down

0 comments on commit e3b09b3

Please sign in to comment.