Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Mar 27, 2024
1 parent 6ac3958 commit 28ae69f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
bun_ci:
uses: cross-org/workflows/.github/workflows/bun-ci.yml@main
with:
jsr_dependencies: "@cross/test @std/assert @cross/runtime @std/path @cross/dir @std/ulid"
jsr_dependencies: "@cross/test @std/assert @cross/runtime @std/path @cross/dir"
node_ci:
uses: cross-org/workflows/.github/workflows/node-ci.yml@main
with:
jsr_dependencies: "@cross/test @std/assert @cross/runtime @std/path @cross/dir @std/ulid"
jsr_dependencies: "@cross/test @std/assert @cross/runtime @std/path @cross/dir"
test_target: "src/**/*.test.ts"
3 changes: 1 addition & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"@cross/runtime": "jsr:@cross/runtime@^1.0.0",
"@cross/test": "jsr:@cross/test@^0.0.9",
"@std/assert": "jsr:@std/assert@^0.220.1",
"@std/path": "jsr:@std/path@^0.220.1",
"@std/ulid": "jsr:@std/ulid@^0.220.1"
"@std/path": "jsr:@std/path@^0.220.1"
},
"publish": {
"exclude": [".github", "*.test.ts"]
Expand Down
13 changes: 7 additions & 6 deletions src/ops/mktempdir.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { dir } from "@cross/dir";
import { ulid } from "@std/ulid";
import { join } from "@std/path";
import { mkdir } from "./mkdir.ts";

Expand All @@ -12,11 +11,13 @@ import { mkdir } from "./mkdir.ts";
*/
export async function mktempdir(prefix?: string): Promise<string> {
const tempBaseDir = await dir("tmp");
let uuid = ulid();
if (prefix) {
uuid = `${prefix}-${uuid}`;
}
const tempDirPath = join(tempBaseDir, uuid.toString());

// Generate a unique identifier without relying on something else
// does not need to be cryptographically perfect
const timestamp = performance.now().toString(36);
const randomPart = Math.random().toString(36).substring(2); // Remove '0.'
const uniqueName = `${prefix ? `${prefix}-` : ""}${timestamp}-${randomPart}`;
const tempDirPath = join(tempBaseDir, uniqueName);
await mkdir(tempDirPath, { recursive: true });
return tempDirPath;
}

0 comments on commit 28ae69f

Please sign in to comment.