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

exportGlobals() should make sure global actually lives in package before dropping #18

Closed
HenrikBengtsson opened this issue Oct 13, 2015 · 0 comments

Comments

@HenrikBengtsson
Copy link
Owner

Internal exportGlobals() should make sure global object actually lives in package before dropping it. This would for instance avoid dropping FUN in if it is assigned as FUN <- base::mean in, say, the global environment.

Currently, exportGlobals() is a bit naive and just trusts the environment of the object;

  pkgs <- packagesOf(globals)
  ## Drop all globals which are already part of one of
  ## the packages in 'pkgs'.  They will be available
  ## when those packages are attached.
  pkgsG <- sapply(globals, FUN=function(obj) {
    environmentName(environment(obj))
  })
  keep <- !is.element(pkgsG, pkgs)
  globals <- globals[keep]

As a start it should make sure the name (by names(globals)) matches.

Related to: Issue HenrikBengtsson/globals#9

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

1 participant