fix scripts

This commit is contained in:
OpportunityLiu
2020-03-20 22:53:43 +08:00
Unverified
parent f8bc635057
commit 470933beed
5 changed files with 29 additions and 20 deletions
+10 -7
View File
@@ -3,8 +3,9 @@ import * as io from '@actions/io';
import * as os from 'os';
import * as path from 'path';
export const folder = path.join(os.tmpdir(), `xmake${Date.now()}`);
const opt = { cwd: folder };
function makeOpt(ref: string): { cwd: string } {
return { cwd: path.join(os.tmpdir(), `xmake-${ref}`) };
}
export async function lsRemote(): Promise<Record<string, string>> {
let out = '';
@@ -25,16 +26,18 @@ export async function lsRemote(): Promise<Record<string, string>> {
}
export async function create(ref: string): Promise<string> {
await io.rmRF(folder);
await io.mkdirP(folder);
const opt = makeOpt(ref);
await io.rmRF(opt.cwd);
await io.mkdirP(opt.cwd);
await exec('git', ['init'], opt);
await exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt);
await exec('git', ['fetch'], opt);
await exec('git', ['checkout', ref], opt);
await exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
return folder;
return opt.cwd;
}
export async function cleanup(): Promise<void> {
await io.rmRF(folder);
export async function cleanup(ref: string): Promise<void> {
const opt = makeOpt(ref);
await io.rmRF(opt.cwd);
}
+1 -1
View File
@@ -47,7 +47,7 @@ async function unixInstall(version: string, sha: string): Promise<void> {
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version);
await io.rmRF(binDir);
await git.cleanup();
await git.cleanup(sha);
return cacheDir;
});
}