in scripts/deno/check-npm-scripts.ts [30:66]
async function getWorkspacePackages(pkgName: string | undefined) {
try {
const command = new Deno.Command('pnpm', {
args: [...(pkgName ? [`--filter`, pkgName] : ['-r']), 'ls', '--json'],
});
const { success, stderr, stdout } = await command.output();
if (!success) {
throw new Error(new TextDecoder().decode(stderr));
}
const result = new TextDecoder().decode(stdout);
const packages = JSON.parse(result) as { path: string }[];
const packageDetails: Package[] = [];
for (const pkg of packages) {
const packageJsonPath = `${pkg.path}/package.json`;
if (await exists(packageJsonPath)) {
const packageJson = JSON.parse(
await Deno.readTextFile(packageJsonPath),
);
if (packageJson.scripts) {
packageDetails.push({
path: pkg.path,
scripts: packageJson.scripts,
});
}
}
}
return packageDetails;
} catch (error) {
console.error('Failed to get workspace packages');
console.error(error);
}
}