atticoos / gulp-ng-config

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

Use a different file name #31

Closed adamski closed 9 years ago

adamski commented 9 years ago

I wish to change the generated file name, e.g. to index.js, is this possible? I don't want to call the json file index.json

atticoos commented 9 years ago

@adamski the best way to go about this would be to pipe it into gulp-rename.

@psalaets just added an Additional Usages section to the readme, i think this is a good candidate to also add since I believe this has been asked before. I'll keep this open as a reminder to add this example to the section

Example:

var gulp = require('gulp'),
    ngConfig = require('gulp-ng-config'),
    rename = require('gulp-rename');

gulp.task('build', function () {
  return gulp.src('config.json')
  .pipe(ngConfig('myApp.config'))
  .pipe(rename('index.js'))
  .pipe(gulp.dest('./src'));
});
atticoos commented 9 years ago

I don't want to call the json file index.json

Just realized you said the output file was index.json -- it should by default change the extension to .js. Was this not the case for you?

adamski commented 9 years ago

Thanks for the tip about rename, was using shell mv for this.

To clarify it is changing the extension to .js as it should be. Its just the filename I wanted to change.

atticoos commented 9 years ago

Cool. I'd definitely choose to suggest the "gulp way" of doing things and drop rename into the piping. Gulp promotes good separation of concerns by delegating a single responsibility to each member of the pipeline, and rename would follow well here!

Cheers

atticoos commented 9 years ago

I believe this is resolved, closing