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

Allow for no json file (and only inline values from gulp) #16

Open
bdwain opened this issue Mar 10, 2015 · 8 comments
Open

Allow for no json file (and only inline values from gulp) #16

bdwain opened this issue Mar 10, 2015 · 8 comments

Comments

@bdwain
Copy link

bdwain commented Mar 10, 2015

the use case i'm thinking of is pass a command line param to gulp and pass that directly to the plugin

gulpNgConfig('myApp.config', {
  constants: {
    apiUrl: argv.apiUrl
  }
});

this would be especially nice since it allows you to avoid putting the value of your constants in source control, which is what drew me to this in the first place.

my workaround for the time being will be to create a json file that is just {}

@atticoos atticoos added this to the v1.1.0 milestone Mar 11, 2015
@atticoos atticoos modified the milestones: v1.2.0, v1.1.0 Mar 29, 2015
@atticoos atticoos modified the milestones: v1.2.0, v1.3.0 Apr 23, 2015
@ThamosIO
Copy link
Contributor

Hi @ajwhite and @bdwain,

I'm thinking of contributing to this issue. Have one of you already started to think about it ?

@atticoos
Copy link
Owner

Nope, feel free

@bdwain
Copy link
Author

bdwain commented May 15, 2015

i haven't either.

@psalaets
Copy link
Contributor

You can achieve this using buffer-to-vinyl.

var b2v = require('buffer-to-vinyl');
var gulpNgConfig = require('gulp-ng-config');

gulp.task('make-config', function() {
  var json = JSON.stringify({
    // your config here
  });

  return b2v.stream(new Buffer(json), 'config.js')
    .pipe(gulpNgConfig('app.config'))
    .pipe(gulp.dest('build'));
});

Is this worth putting in the readme? I can whip up a PR.

@atticoos
Copy link
Owner

@psalaets great call, one of the beautiful things about streams is that we can & should be extremely modular and allow for single responsibility -- piping the result of that into gulpNgConfig would be ideal here. We can add an "Additional Usages" section that shows how this can be integrated with other preceding or proceeding streams. I think this is a great entry to start off a new "Additional Usages" section. Feel free to PR!

atticoos added a commit that referenced this issue Jun 22, 2015
Started 'Additional Usages' section with example for issue #16
@bdwain
Copy link
Author

bdwain commented Jun 24, 2015

that works, but it seems a little weird to me to require an extra module to read what you already have in code. It seems more logical to me to require something extra to read configs from a file (and default to only inline objects), though since it's already implemented this way, might not be worth changing.

@atticoos
Copy link
Owner

When it comes to the principles behind a stream build system, a gulp plugin only serves as a stage (pipe) of the stream. To build around edges where there might not be a source of a stream, it kind of defeats the purpose of how a gulp plugin is intended to work -- there needs to be a stream source. The source, in this case, should be responsible for taking your command line args, creating your JSON object, and beginning a new readable stream.

@atticoos atticoos modified the milestones: v1.3.0, v1.4.0 Nov 17, 2015
@atticoos
Copy link
Owner

Think I'm going to take a look at this for 1.4.0

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

4 participants