Skip to content

Commit

Permalink
chore: add script for listing required Node.js versions for dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Jul 2, 2023
1 parent 6ad9fae commit 017c183
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/list-dependency-node-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { readFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'

import chalk from 'chalk'
import { execa } from 'execa'

const __dirname = dirname(fileURLToPath(import.meta.url))

const importJson = async (path) => JSON.parse(await readFile(pathToFileURL(join(__dirname, path))))

const { dependencies } = await importJson('../package.json')

console.log(chalk.dim('Listing required Node.js versions for dependencies:'))
console.log(chalk.dim('---------------------------------------------------'))

for (const dependency of Object.keys(dependencies)) {
const { all } = await execa('npm', ['info', dependency, 'engines.node'], {
all: true,
cwd: __dirname,
})

console.log(`${chalk.greenBright(dependency)}:`, all || chalk.dim('-'))
}

0 comments on commit 017c183

Please sign in to comment.