atticoos / gulp-ng-config

:wrench: Create AngularJS constants from a JSON config file
MIT License
173 stars 35 forks source link

New "keys" option to select which keys you want to import #60

Closed felixhorro closed 6 years ago

felixhorro commented 7 years ago

If you only want some of the keys from the object imported, you can supply the keys you want the plugin to load.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3ae7df4e2d0465ea87ee2fb3519079c8c392106d on felixhorro:develop into b6e1c45be74842fe405c6d05770520d484095e12 on ajwhite:develop.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3ae7df4e2d0465ea87ee2fb3519079c8c392106d on felixhorro:develop into b6e1c45be74842fe405c6d05770520d484095e12 on ajwhite:develop.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3ae7df4e2d0465ea87ee2fb3519079c8c392106d on felixhorro:develop into b6e1c45be74842fe405c6d05770520d484095e12 on ajwhite:develop.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3ae7df4e2d0465ea87ee2fb3519079c8c392106d on felixhorro:develop into b6e1c45be74842fe405c6d05770520d484095e12 on ajwhite:develop.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3ae7df4e2d0465ea87ee2fb3519079c8c392106d on felixhorro:develop into b6e1c45be74842fe405c6d05770520d484095e12 on ajwhite:develop.

atticoos commented 7 years ago

Support added to existing options.environment in #61

atticoos commented 7 years ago

This is now published under the v1.4.0 release

felixhorro commented 7 years ago

Thanks, but #61 doesn't fit my needs.

As an example, I want to expose app version as an angular constant, so I use gulp-ng-config to get it from the package.json of my project. I only need "version" property, don't want to make "name", "description", "dependencies", etc. constants.

Thanks!

atticoos commented 7 years ago

I see, so you want the specified key to actually be added to the constant, not just the children.

For example:

{
  "wanted": "foobar",
  "environmentA": {
    "hello": "world"
  }
}

Using environment

gulpNgConfig('appConfig', {
  environment: 'environmentA'
})

Will produce

angular.module('appConfig', [])
.constant('hello', 'world')

What you want is to actually specify that key and have it become part of the output:

gulpNgConfig('appConfig', {
  keys: 'environmentA'
})

Producing

angular.module('appConfig', [])
.constant('environmentA', {'hello': 'world'})

Is this accurate?

atticoos commented 7 years ago

@felixhorro let me know on the above, we can still look at this. And since we have a bunch of conflicts, let me know if you still want to address this, or otherwise I'm happy to.

felixhorro commented 7 years ago

@ajwhite You're right, I need the key to be imported, not the children.

Conflicts solved!

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling c5040b2457487367ae3863017c0a5bbb74e1d0c8 on felixhorro:develop into 76307eb4cb527112e10116bfe2a4afa9d46be791 on ajwhite:develop.

felixhorro commented 6 years ago

:tada: :tada: :confetti_ball: :confetti_ball: :tada: :tada: Thanks!