Skip to content

Instantly share code, notes, and snippets.

@CreeJee
Created July 6, 2024 14:34
만약 이걸로 next/standalone 에서 .yarn파일만 드르륵 긁을수 있다면?
import { exec } from 'child_process';
import { cp } from 'fs/promises';
import { basename } from 'path';
import { promisify } from 'util';
const cwd = process.cwd();
const execPromise = promisify(exec);
type PackageInfoType = {
value: string;
children: {
Version: string;
Cache: {
Checksum: string;
Path: string;
Size: number;
};
Dependents: string[];
};
};
const init = async () => {
const yarnProcessOut = await execPromise('yarn info --recursive --dependents --json --cache', {
cwd,
maxBuffer: Infinity,
});
const packageInfoList = yarnProcessOut.stdout
.split('\n')
.slice(0, -1)
.map((v) => JSON.parse(v) as PackageInfoType);
const packagePaths = Array.from(
new Set(packageInfoList.map((v) => v.children.Cache.Path)).values(),
);
await Promise.allSettled(
packagePaths.map((path) =>
cp(path, `${cwd}/.next/standalone/quotabook-frontend/.yarn/cache/${basename(path)}`),
),
);
};
init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment