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
Vendored
+10 -7
View File
@@ -4,8 +4,9 @@ const exec_1 = require("@actions/exec");
const io = require("@actions/io"); const io = require("@actions/io");
const os = require("os"); const os = require("os");
const path = require("path"); const path = require("path");
exports.folder = path.join(os.tmpdir(), `xmake${Date.now()}`); function makeOpt(ref) {
const opt = { cwd: exports.folder }; return { cwd: path.join(os.tmpdir(), `xmake-${ref}`) };
}
async function lsRemote() { async function lsRemote() {
let out = ''; let out = '';
await exec_1.exec('git', ['ls-remote', '--tags', 'https://github.com/xmake-io/xmake.git'], { await exec_1.exec('git', ['ls-remote', '--tags', 'https://github.com/xmake-io/xmake.git'], {
@@ -25,17 +26,19 @@ async function lsRemote() {
} }
exports.lsRemote = lsRemote; exports.lsRemote = lsRemote;
async function create(ref) { async function create(ref) {
await io.rmRF(exports.folder); const opt = makeOpt(ref);
await io.mkdirP(exports.folder); await io.rmRF(opt.cwd);
await io.mkdirP(opt.cwd);
await exec_1.exec('git', ['init'], opt); await exec_1.exec('git', ['init'], opt);
await exec_1.exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt); await exec_1.exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt);
await exec_1.exec('git', ['fetch'], opt); await exec_1.exec('git', ['fetch'], opt);
await exec_1.exec('git', ['checkout', ref], opt); await exec_1.exec('git', ['checkout', ref], opt);
await exec_1.exec('git', ['submodule', 'update', '--init', '--recursive'], opt); await exec_1.exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
return exports.folder; return opt.cwd;
} }
exports.create = create; exports.create = create;
async function cleanup() { async function cleanup(ref) {
await io.rmRF(exports.folder); const opt = makeOpt(ref);
await io.rmRF(opt.cwd);
} }
exports.cleanup = cleanup; exports.cleanup = cleanup;
+1 -1
View File
@@ -47,7 +47,7 @@ async function unixInstall(version, sha) {
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir }); await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version); const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version);
await io.rmRF(binDir); await io.rmRF(binDir);
await git.cleanup(); await git.cleanup(sha);
return cacheDir; return cacheDir;
}); });
} }
+7 -4
View File
@@ -1,16 +1,19 @@
{ {
"name": "github-action-setup-xmake", "name": "github-action-setup-xmake",
"version": "1.0.1", "version": "1.0.3",
"description": "Set up your GitHub Actions workflow with a specific version of xmake", "description": "Set up your GitHub Actions workflow with a specific version of xmake",
"main": "dist/index.js", "main": "dist/index.js",
"author": "OpportunityLiu", "author": "OpportunityLiu",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"repository": "https://github.com/xmake-io/github-action-setup-xmake.git",
"homepage": "https://github.com/xmake-io/github-action-setup-xmake",
"scripts": { "scripts": {
"clean": "rimraf dist", "init": "yarn install && yarn clean",
"watch": "tsc --watch", "watch": "tsc --watch",
"lint": "eslint --fix src/**/*",
"build": "tsc --build ./tsconfig.build.json", "build": "tsc --build ./tsconfig.build.json",
"rebuild":"yarn clean && yarn build", "rebuild": "yarn clean && yarn build",
"clean": "rimraf dist",
"lint": "eslint --fix src/**/*",
"test": "jest", "test": "jest",
"release": "yarn rebuild && yarn lint && yarn install --production" "release": "yarn rebuild && yarn lint && yarn install --production"
}, },
+10 -7
View File
@@ -3,8 +3,9 @@ import * as io from '@actions/io';
import * as os from 'os'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
export const folder = path.join(os.tmpdir(), `xmake${Date.now()}`); function makeOpt(ref: string): { cwd: string } {
const opt = { cwd: folder }; return { cwd: path.join(os.tmpdir(), `xmake-${ref}`) };
}
export async function lsRemote(): Promise<Record<string, string>> { export async function lsRemote(): Promise<Record<string, string>> {
let out = ''; let out = '';
@@ -25,16 +26,18 @@ export async function lsRemote(): Promise<Record<string, string>> {
} }
export async function create(ref: string): Promise<string> { export async function create(ref: string): Promise<string> {
await io.rmRF(folder); const opt = makeOpt(ref);
await io.mkdirP(folder); await io.rmRF(opt.cwd);
await io.mkdirP(opt.cwd);
await exec('git', ['init'], opt); await exec('git', ['init'], opt);
await exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt); await exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt);
await exec('git', ['fetch'], opt); await exec('git', ['fetch'], opt);
await exec('git', ['checkout', ref], opt); await exec('git', ['checkout', ref], opt);
await exec('git', ['submodule', 'update', '--init', '--recursive'], opt); await exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
return folder; return opt.cwd;
} }
export async function cleanup(): Promise<void> { export async function cleanup(ref: string): Promise<void> {
await io.rmRF(folder); 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 }); await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version); const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version);
await io.rmRF(binDir); await io.rmRF(binDir);
await git.cleanup(); await git.cleanup(sha);
return cacheDir; return cacheDir;
}); });
} }