Skip to content

Instantly share code, notes, and snippets.

@daKmoR
Forked from zkat/index.js
Last active March 21, 2019 22:31
Show Gist options
  • Save daKmoR/b509ed34576a488ea79d3ac66ccab74e to your computer and use it in GitHub Desktop.
Save daKmoR/b509ed34576a488ea79d3ac66ccab74e to your computer and use it in GitHub Desktop.
npx is cool

Hi!

try passing the URL for this gist to npx.

npx https://gist.github.com/daKmoR/b509ed34576a488ea79d3ac66ccab74e

Will output something like this:

$ npx https://gist.github.com/daKmoR/b509ed34576a488ea79d3ac66ccab74e
npx: installed 1 in 5.344s
$ node --version
v10.9.0

$ npm --version
6.4.1

$ cat /proc/version:
It is a WSL (Windows Subystem Linux)
Linux version 4.4.0-17134-Microsoft ([email protected]) (gcc version 5.4.0 (GCC) ) #285-Microsoft Thu Aug 30 17:31:00 PST 2018

$ lsb_release -a:
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial
#!/usr/bin/env node
const util = require('util');
const exec = util.promisify(require('child_process').exec);
async function systemVersionInfos() {
const { stdout: nodeVersion } = await exec('node --version');
console.log('$ node --version');
console.log(nodeVersion);
const { stdout: npmVersion } = await exec('npm --version');
console.log('$ npm --version');
console.log(npmVersion);
const { stdout: wslVersion } = await exec('cat /proc/version');
if (wslVersion) {
console.log('$ cat /proc/version:');
if (wslVersion.includes('Microsoft')) {
console.log('It is a WSL (Windows Subystem Linux)');
}
console.log(wslVersion);
}
const { stdout: linuxVersion } = await exec('lsb_release -a');
if (linuxVersion) {
console.log('$ lsb_release -a:');
console.log(linuxVersion);
}
}
systemVersionInfos();
{
"name": "get-versions",
"version": "0.0.0",
"bin": "./index.js",
"engines" : {
"node" : ">11.8.0",
"npm" : ">8.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment