Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose installation context into process #2472

Open
cdaringe opened this issue Jan 16, 2017 · 1 comment
Open

expose installation context into process #2472

cdaringe opened this issue Jan 16, 2017 · 1 comment

Comments

@cdaringe
Copy link

cdaringe commented Jan 16, 2017

What is the current behavior?

Greetings!

npm exposes the following process.env.npm_config_global. this enables me to determine what context i am operating in during installation. i do not see such a thing present for yarn.

i understand that this could invoke some fear or questioning.

"why would you ever want or need that? you're probably doing something wrong!" --say concerned citizens

there's actually a plenty valid use case. my use case is that I have a package who's objective is to modify the consumer's package oninstall. because this pkg ships as a dep in other packages, some of which get installed globally, i care to detect this condition and respond accordingly.

Please mention your node.js, yarn and operating system version.

  • node 7.4.0
  • yarn 0.18.1
@rally25rs
Copy link
Contributor

Could be a good first contrib for someone; determine what env variables NPM makes available during script execution, and mimic them in Yarn.

oh ok, I'll do the first step... 👟

Add this script to package.json

  "scripts": {
    "test": "env | grep npm_"
  },

and then run npm test and get these env vars being set:

npm_config_save_dev=
npm_config_legacy_bundling=
npm_config_dry_run=
npm_config_viewer=man
npm_config_only=
npm_config_browser=
npm_config_also=
npm_config_rollback=true
npm_config_usage=
npm_config_globalignorefile=/Users/me/.nvm/versions/node/v8.0.0/etc/npmignore
npm_config_shell=/bin/bash
npm_config_maxsockets=50
npm_config_init_author_url=
npm_config_shrinkwrap=true
npm_config_parseable=
npm_config_metrics_registry=https://registry.npmjs.org/
npm_config_timing=
npm_config_init_license=ISC
npm_config_if_present=
npm_config_sign_git_tag=
npm_config_init_author_email=
npm_config_cache_max=Infinity
npm_config_long=
npm_config_local_address=
npm_config_git_tag_version=true
npm_config_cert=
npm_config_registry=https://registry.npmjs.org/
npm_config_fetch_retries=2
npm_config_versions=
npm_config_message=%s
npm_config_key=
npm_package_devDependencies_react=^15.6.1
npm_package_description=
npm_package_license=ISC
npm_config_globalconfig=/Users/me/.nvm/versions/node/v8.0.0/etc/npmrc
npm_config_prefer_online=
npm_config_logs_max=10
npm_config_always_auth=
npm_execpath=/Users/me/.nvm/versions/node/v8.0.0/lib/node_modules/npm/bin/npm-cli.js
npm_config_global_style=
npm_config_cache_lock_retries=10
npm_config_cafile=
npm_config_heading=npm
npm_config_searchlimit=20
npm_config_proprietary_attribs=true
npm_config_offline=
npm_config_fetch_retry_mintimeout=10000
npm_config_json=
npm_config_access=
npm_config_argv={"remain":[],"cooked":["test"],"original":["test"]}
npm_config_allow_same_version=
npm_config_https_proxy=
npm_config_engine_strict=
npm_config_description=true
npm_config_userconfig=/Users/me/.npmrc
npm_config_init_module=/Users/me/.npm-init.js
npm_package_author=
npm_config_user=1939786327
npm_config_node_version=8.0.0
npm_lifecycle_event=test
npm_config_save=true
npm_config_ignore_prepublish=
npm_config_editor=vi
npm_config_auth_type=legacy
npm_package_name=yarn-test
npm_config_tag=latest
npm_config_global=
npm_config_progress=
npm_config_searchstaleness=900
npm_config_optional=true
npm_config_ham_it_up=
npm_config_save_prod=
npm_config_force=
npm_config_bin_links=true
npm_config_searchopts=
npm_config_depth=Infinity
npm_package_main=index.js
npm_config_sso_poll_frequency=500
npm_config_rebuild_bundle=true
npm_package_version=1.0.0
npm_config_unicode=true
npm_config_fetch_retry_maxtimeout=60000
npm_package_scripts_test=env | grep npm_
npm_config_tag_version_prefix=v
npm_config_strict_ssl=true
npm_config_sso_type=oauth
npm_config_scripts_prepend_node_path=warn-only
npm_config_save_prefix=^
npm_config_loglevel=notice
npm_config_ca=
npm_config_save_exact=
npm_config_group=891112136
npm_config_fetch_retry_factor=10
npm_config_dev=
npm_config_version=
npm_config_prefer_offline=
npm_config_cache_lock_stale=60000
npm_config_cache_min=10
npm_config_searchexclude=
npm_config_cache=/Users/jvalore/.npm
npm_lifecycle_script=env | grep npm_
npm_config_color=true
npm_config_proxy=
npm_config_package_lock=true
npm_config_save_optional=
npm_config_ignore_scripts=
npm_config_user_agent=npm/5.0.3 node/v8.0.0 darwin x64
npm_config_cache_lock_wait=10000
npm_config_production=
npm_config_send_metrics=
npm_config_save_bundle=
npm_config_umask=0022
npm_config_init_version=1.0.0
npm_config_init_author_name=
npm_config_git=git
npm_config_scope=
npm_config_unsafe_perm=true
npm_config_tmp=/var/folders/yf/gcmnw1y96k31lh9ttjhfm8v9ssxkkq/T
npm_config_onload_script=
npm_node_execpath=/Users/me/.nvm/versions/node/v8.0.0/bin/node
npm_config_prefix=/Users/me/.nvm/versions/node/v8.0.0
npm_config_link=

Wow, that's a lot of stuff...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants