Skip to content

Commit

Permalink
Merge pull request #185 from masx200/format-updates
Browse files Browse the repository at this point in the history
format
  • Loading branch information
masx200 authored Apr 27, 2024
2 parents b45508f + 500485a commit 2dfd9ff
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
19 changes: 10 additions & 9 deletions cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (import.meta.main) {

async function parallel_cache(
entry_iter: AsyncIterableIterator<WalkEntry>,
limiter: AsyncCurrentLimiter,
limiter: AsyncCurrentLimiter
) {
const files: string[] = [];

Expand All @@ -37,20 +37,21 @@ async function parallel_cache(
limiter.run(
function (stack: string[]) {
return runDenocache(stack);
}.bind(null, stack),
}.bind(null, stack)
)
),
)
);
}
async function start() {
const limiter = new AsyncLimiterClass(1);
const args = parse(Deno.args);
console.log(args);
const skip = typeof args.skip === "string"
? new RegExp(String(args.skip))
: Array.isArray(args.skip)
? args.skip.map((s: string | RegExp) => new RegExp(s))
: undefined;
const skip =
typeof args.skip === "string"
? new RegExp(String(args.skip))
: Array.isArray(args.skip)
? args.skip.map((s: string | RegExp) => new RegExp(s))
: undefined;
const entry_iter = searchFilesNames({ skip });
await parallel_cache(entry_iter, limiter);
}
Expand All @@ -72,7 +73,7 @@ async function runDenocache(stack: string[]) {
if (!success) {
throw new Error(
"type cache failed:" +
JSON.stringify({ code, success, stdout: out, stderr: err }),
JSON.stringify({ code, success, stdout: out, stderr: err })
);
}
}
19 changes: 10 additions & 9 deletions check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (import.meta.main) {

async function parallel_check(
entry_iter: AsyncIterableIterator<WalkEntry>,
limiter: AsyncCurrentLimiter,
limiter: AsyncCurrentLimiter
) {
const files: string[] = [];

Expand All @@ -37,20 +37,21 @@ async function parallel_check(
limiter.run(
function (stack: string[]) {
return runDenoCheck(stack);
}.bind(null, stack),
}.bind(null, stack)
)
),
)
);
}
async function start() {
const limiter = new AsyncLimiterClass(navigator.hardwareConcurrency);
const args = parse(Deno.args);
console.log(args);
const skip = typeof args.skip === "string"
? new RegExp(String(args.skip))
: Array.isArray(args.skip)
? args.skip.map((s: string | RegExp) => new RegExp(s))
: undefined;
const skip =
typeof args.skip === "string"
? new RegExp(String(args.skip))
: Array.isArray(args.skip)
? args.skip.map((s: string | RegExp) => new RegExp(s))
: undefined;
const entry_iter = searchFilesNames({ skip });
await parallel_check(entry_iter, limiter);
}
Expand All @@ -72,7 +73,7 @@ async function runDenoCheck(stack: string[]) {
if (!success) {
throw new Error(
"type cache failed:" +
JSON.stringify({ code, success, stdout: out, stderr: err }),
JSON.stringify({ code, success, stdout: out, stderr: err })
);
}
}
2 changes: 1 addition & 1 deletion retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function retry<T>(
retryOnError?:
| ((error: any) => Promise<boolean>)
| ((error: any) => boolean);
},
}
) {
const retryOnError = opts?.retryOnError ?? (() => true);
const options: Required<RetryOptions> = {
Expand Down
17 changes: 9 additions & 8 deletions xmake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { retry } from "./retry.ts";

async function* findFilesRecursive(
path: string,
name: string,
name: string
): AsyncGenerator<string, void, unknown> {
for await (const entry of Deno.readDir(path)) {
const fullPath = resolve(join(path, entry.name));
Expand Down Expand Up @@ -37,7 +37,7 @@ async function RunXmake(
sdk: string,
executable: string,
group: string,
mode: string,
mode: string
) {
await RunXmakeConfig(file, toolchain, sdk, executable, mode);
await retry(RunXmakeBuild.bind(null, file, executable, group), {
Expand All @@ -50,11 +50,11 @@ async function RunXmake(
const cwd = path.dirname(file);
const dirtobecreate = path.join(
cwd,
path.dirname(filepathmatched),
path.dirname(filepathmatched)
);

console.log(
"Ensures that the directory exists:" + dirtobecreate,
"Ensures that the directory exists:" + dirtobecreate
);
await ensureDir(dirtobecreate);
return true;
Expand All @@ -69,7 +69,7 @@ async function RunXmakeConfig(
toolchain: string,
sdk: string,
executable: string,
mode: string,
mode: string
) {
console.log({ file });
const cwd = path.dirname(file);
Expand All @@ -88,9 +88,10 @@ export async function RunCommandShell(others: string[], cwd?: string) {

const cmd = os === "windows" ? "powershell.exe" : "bash";

const args = os === "windows"
? ["-command", others.join(" \n ")]
: ["-c", others.join(" && ")];
const args =
os === "windows"
? ["-command", others.join(" \n ")]
: ["-c", others.join(" && ")];

console.log(JSON.stringify({ cmd, cwd, args }));
const command = new Deno.Command(cmd, { cwd: cwd, args });
Expand Down

0 comments on commit 2dfd9ff

Please sign in to comment.