Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format #179

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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