Last active
October 1, 2019 17:42
-
-
Save shisama/1c857b7ae25904a5b67ae5cef27b3613 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env node | |
const path = require('path') | |
const execa = require('execa'); | |
const problemPackage = 'cowsay'; | |
const {devDependencies, dependencies} = require(path.resolve(__dirname, 'package.json')); | |
const problemPackageVersion = {...devDependencies, ...dependencies}[problemPackage] | |
const execSync = require('child_process').execSync; | |
const execCommand = (command, fallback) => { | |
try { | |
return execSync(command); | |
} catch (err) { | |
return fallback; | |
} | |
} | |
const nodeVersion = execCommand('node -v', 'Can\'t find node\n'); | |
const yarnVersion = execCommand('yarn -v', 'Can\'t find yarn\n') | |
const npmVersion = execCommand('npm -v', 'Can\'t find npm\n'); | |
const report = `package version : ${problemPackageVersion}\nnode version : ${nodeVersion}yarn version : ${yarnVersion}npm version : ${npmVersion}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
console.log(report) prints the below.