Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

More robust pnpm import

Chocobozzz3cfcfef953e9
diff --git a/server/core/lib/plugins/package-manager.ts b/server/core/lib/plugins/package-manager.ts
index bb85788bc0..030d080954 100644
--- a/server/core/lib/plugins/package-manager.ts
+++ b/server/core/lib/plugins/package-manager.ts
@@ -72,12 +72,16 @@ export async function initPNPM () {
await outputJSON(pluginPackageJSON, {})
} else {
- let packageJSONContent = await readFile(pluginPackageJSON, 'utf-8')
+ try {
+ let packageJSONContent = await readFile(pluginPackageJSON, 'utf-8')
- if (packageJSONContent.includes('"packageManager"')) {
- packageJSONContent = packageJSONContent.replace(/\s*"packageManager".*/g, '')
+ if (packageJSONContent.includes('"packageManager"')) {
+ packageJSONContent = packageJSONContent.replace(/\s*"packageManager".*/g, '')
- await writeFile(pluginPackageJSON, packageJSONContent, 'utf-8')
+ await writeFile(pluginPackageJSON, packageJSONContent, 'utf-8')
+ }
+ } catch (err) {
+ logger.error('Cannot sanitize package.json in plugin directory', { err })
}
}
@@ -91,7 +95,14 @@ export async function initPNPM () {
if (await pathExists(join(pluginDirectory, 'yarn.lock'))) {
logger.info('Migrate from yarn.lock in plugin directory')
- await execPNPM('import yarn.lock')
- await remove(join(pluginDirectory, 'yarn.lock'))
+ try {
+ await execPNPM('import')
+ await remove(join(pluginDirectory, 'yarn.lock'))
+ } catch (err) {
+ logger.error(
+ 'Cannot migrate from yarn.lock in plugin directory. Please fix this error to not break PeerTube plugins/themes.',
+ { err }
+ )
+ }
}
}