Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Detect invocation came from npx #167

@jdalton

Description

@jdalton

I'm working on a project creation template create-esm and it would be great to be able to detect that npx invoked it so that I can defer to npm init, instead of say, yarn init.

My guess is that this could be done through an environment variable that is set for the executed child process.

Update:

On MacOS at least the process.env._ variable holds the executing path
'/Users/jdalton/.nvm/versions/node/v9.9.0/bin/npx'

I'm currently looking into process.ppid and pidtree.

Update:

Ah, it looks like NPX_CLI_JS is set! ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions