silverwolf-x's picture
download
raw
1.1 kB
import findUp from 'next/dist/compiled/find-up'
const EVENT_PLUGIN_PRESENT = 'NEXT_PACKAGE_DETECTED'
type NextPluginsEvent = {
eventName: string
payload: {
packageName: string
packageVersion: string
}
}
export async function eventNextPlugins(
dir: string
): Promise<Array<NextPluginsEvent>> {
try {
const packageJsonPath = await findUp('package.json', { cwd: dir })
if (!packageJsonPath) {
return []
}
const { dependencies = {}, devDependencies = {} } = require(packageJsonPath)
const deps = { ...devDependencies, ...dependencies }
return Object.keys(deps).reduce(
(events: NextPluginsEvent[], plugin: string): NextPluginsEvent[] => {
const version = deps[plugin]
// Don't add deps without a version set
if (!version) {
return events
}
events.push({
eventName: EVENT_PLUGIN_PRESENT,
payload: {
packageName: plugin,
packageVersion: version,
},
})
return events
},
[]
)
} catch (_) {
return []
}
}

Xet Storage Details

Size:
1.1 kB
·
Xet hash:
46e7070f076b0dada14c683d774a014026c5ce23d7e67dc4b1fee5a3a8a37b67

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.