Skip to content

Instantly share code, notes, and snippets.

@sjelfull
Forked from zkat/index.js
Last active August 25, 2022 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjelfull/60ee5d672ddb1d31195e54e6ad655ba0 to your computer and use it in GitHub Desktop.
Save sjelfull/60ee5d672ddb1d31195e54e6ad655ba0 to your computer and use it in GitHub Desktop.
npx is cool

Hi!

try passing the URL for this gist to npx.

#!/usr/bin/env node
const isNpx = process.argv.some((segment) => segment.includes('_npx') || segment.includes('npx'))
console.log('yay gist');
console.log(process.argv, process.argv0);
console.log(`${isNpx ? 'likely npx' : 'not likely to be npx'}`)
console.log(process.env)
console.log(['env._ ends with npx', process.env._.endsWith('/npx')])
{"name": "npx-is-cool", "version": "0.0.0", "bin": "./index.js"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment