Created
July 6, 2024 14:34
-
-
Save CreeJee/4d41b421ed0db3c427cd1d63e8038a05 to your computer and use it in GitHub Desktop.
만약 이걸로 next/standalone 에서 .yarn파일만 드르륵 긁을수 있다면?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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