Lines 1-24javascript
1import { createHash, randomBytes } from 'node:crypto';
2import { cp, copyFile, link, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, rmdir, stat, unlink, } from 'node:fs/promises';
3import { basename, dirname, join, resolve } from 'node:path';
4import { fileURLToPath, pathToFileURL } from 'node:url';
5const LAUNCHER_SOURCE = "const u=Buffer.from(process.argv[1],'base64url').toString('utf8');process.argv[1]=require('node:url').fileURLToPath(u);import(u).catch(e=>{console.error(e);process.exitCode=1})";
6const OWNER_PATTERN = /^[a-z0-9-]+$/;
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/lib/installerSupport.jsView on unpkg · L4 7const TOKEN_PATTERN = /^[A-Za-z0-9_-]+$/;
8const LOCK_STALE_MS = 120_000;
9const LOCK_RETRIES = 100;
10const LOCK_RETRY_MS = 20;
11function errorCode(error) {
12 return error && typeof error === 'object' && 'code' in error
16export function buildManagedCommand(targetPath, owner) {
17 if (!OWNER_PATTERN.test(owner))
18 throw new Error(`Invalid Mnemonik command owner: ${owner}`);
19 const token = Buffer.from(pathToFileURL(resolve(targetPath)).href, 'utf8').toString('base64url');
20 return `node -e ${JSON.stringify(LAUNCHER_SOURCE)} -- ${token} --mnemonik-owner=${owner}`;
22export function parseManagedCommand(command, owner) {
23 if (!OWNER_PATTERN.test(owner))