增加js-runner的skill
This commit is contained in:
14
skills/js-runner/scripts/get_temp_path.js
Normal file
14
skills/js-runner/scripts/get_temp_path.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { tmpdir } from "os";
|
||||
import { join } from "path";
|
||||
|
||||
export function getTempPath(extension) {
|
||||
const timestamp = Date.now();
|
||||
const random = Math.random().toString(36).substring(7);
|
||||
return join(tmpdir(), `js-runner-${timestamp}-${random}.${extension}`);
|
||||
}
|
||||
|
||||
// CLI interface: accepts extension as first argument
|
||||
if (import.meta.main) {
|
||||
const extension = process.argv[2] || "js";
|
||||
console.log(getTempPath(extension));
|
||||
}
|
||||
Reference in New Issue
Block a user