Skip to content

Commit

Permalink
fix package cache
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 15, 2025
1 parent 2e6893d commit 87a41ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/build-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ async function getBuildCachePath(): Promise<string> {
const projectRootPath = getProjectRootPath();
if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
const options: ExecOptions = {};
options.env = {
...process.env,
XMAKE_ROOT: 'y'
};
options.cwd = projectRootPath;
options.listeners = {
stdout: (data: Buffer) => {
Expand Down Expand Up @@ -153,7 +157,12 @@ export async function saveBuildCache(): Promise<void> {
await io.cp(buildCachePath, fullCachePath, {
recursive: true,
});
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'build_cache_saved.txt')]);
const options: ExecOptions = {};
options.env = {
...process.env,
XMAKE_ROOT: 'y'
};
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'build_cache_saved.txt')], options);
await cache.saveCache([buildCacheFolder], buildCacheKey);
}
}
14 changes: 14 additions & 0 deletions src/package-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ async function getPackageCacheKey(): Promise<string> {
const projectRootPath = getProjectRootPath();
if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
const options: ExecOptions = {};
options.env = {
...process.env,
XMAKE_ROOT: 'y'
};
options.cwd = projectRootPath;
options.listeners = {
stdout: (data: Buffer) => {
Expand All @@ -43,6 +47,10 @@ async function getPackageCacheKey(): Promise<string> {
async function getPackageCachePath(): Promise<string> {
let packageCachePath = '';
const options: ExecOptions = {};
options.env = {
...process.env,
XMAKE_ROOT: 'y'
};
options.listeners = {
stdout: (data: Buffer) => {
packageCachePath += data.toString();
Expand Down Expand Up @@ -112,6 +120,12 @@ export async function savePackageCache(): Promise<void> {
await io.cp(packageCachePath, fullCachePath, {
recursive: true,
});
const options: ExecOptions = {};
options.env = {
...process.env,
XMAKE_ROOT: 'y'
};
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'package_cache_saved.txt')], options);
await cache.saveCache([packageCacheFolder], packageCacheKey);
}
}

0 comments on commit 87a41ca

Please sign in to comment.