atticoos / gulp-ng-config

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

custom wrapper incorrect because of trailing colon #73

Closed fariasfrancisco closed 6 years ago

fariasfrancisco commented 6 years ago

I have the following custom wrapper:

wrap: '\'use strict\'\n\nimport angular from \'angular\'\n\nexport default <%= module %>\n  .name\n'

the expected output is:

'use strict'

import angular from 'angular'

export default angular.module("sisaApp.config", [])
.constant("environment", "development")
  .name

but I get this:

'use strict'

import angular from 'angular'

export default angular.module("sisaApp.config", [])
.constant("environment", "development");

  .name

the ; screws up with my code. I don't use ; because I follow standardjs.

atticoos commented 6 years ago

Sorry that you ran into some trouble here!

Try using the templateFilePath and defining a custom template without the semi colon:

We'll basically take the existing template and remove the ;

export default angular.module("<%= moduleName %>"<% if (createModule) { %>, []<% } %>)<% _.forEach(constants, function (constant) { %>
.<%= type %>("<%= constant.name %>", <%= constant.value %>)<% }) %>
fariasfrancisco commented 6 years ago

Thanks!!!