mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
@@ -5,10 +5,11 @@ type RunOptions = {
|
||||
script: string;
|
||||
input?: Buffer | string;
|
||||
secrets?: Record<string, string>;
|
||||
cacheLocation: string;
|
||||
};
|
||||
|
||||
const run = async ({ script, input, secrets }: RunOptions) => {
|
||||
const info = await setup({ script, input, secrets });
|
||||
const run = async ({ script, input, secrets, cacheLocation }: RunOptions) => {
|
||||
const info = await setup({ script, input, secrets, cacheLocation });
|
||||
|
||||
const worker = new Worker(info.scriptLocation, {
|
||||
stdin: false,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { join } from 'path';
|
||||
import os from 'os';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { chmod, mkdir, rm, writeFile } from 'fs/promises';
|
||||
import { createServer } from 'net';
|
||||
@@ -9,6 +8,7 @@ type SetupOptions = {
|
||||
input?: Buffer | string;
|
||||
script: string;
|
||||
secrets?: Record<string, string>;
|
||||
cacheLocation: string;
|
||||
};
|
||||
|
||||
type RunEvents = {
|
||||
@@ -20,7 +20,7 @@ type RunEvents = {
|
||||
const setup = async (options: SetupOptions) => {
|
||||
const { input, script, secrets } = options;
|
||||
const emitter = new EventEmitter<RunEvents>();
|
||||
const dataDir = join(os.tmpdir(), 'mini-loader', nanoid());
|
||||
const dataDir = join(options.cacheLocation, nanoid());
|
||||
|
||||
await mkdir(dataDir, { recursive: true });
|
||||
await chmod(dataDir, 0o700);
|
||||
|
||||
Reference in New Issue
Block a user