Skip to content

Commit

Permalink
Fix issue with linters that prefer single quotes
Browse files Browse the repository at this point in the history
Activity: /issues/12

I ran into [this issue](/issues/12) as well where linters (Sonarlint in my case) take
exception to the double-quotes output. I've changed the template and
test files to use single-quotes and am using .replace on the
template.constant.value to replace double-quotes with single-quotes.

Tests pass.
  • Loading branch information
Adam Merrifield committed Sep 9, 2016
1 parent b6e1c45 commit 17490cb
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions gulp-ng-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var through = require('through2'),
PluginError = gutil.PluginError,
VALID_TYPES = ['constant', 'value'],
PLUGIN_NAME = 'gulp-ng-config',
WRAP_TEMPLATE = '(function () { \n return <%= module %>\n})();\n',
WRAP_TEMPLATE = '(function () {\n return <%= module %>\n})();\n',
ES6_TEMPLATE = 'import angular from \'angular\';\nexport default <%= module %>';

function gulpNgConfig (moduleName, configuration) {
Expand Down Expand Up @@ -104,7 +104,7 @@ function gulpNgConfig (moduleName, configuration) {
_.each(jsonObj, function (value, key) {
constants.push({
name: key,
value: JSON.stringify(value, null, spaces)
value: JSON.stringify(value, null, spaces).replace(/"/g, '\'')
});
});

Expand Down
4 changes: 2 additions & 2 deletions template.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("<%= moduleName %>"<% if (createModule) { %>, []<% } %>)<% _.forEach(constants, function (constant) { %>
.<%= type %>("<%= constant.name %>", <%= constant.value %>)<% }); %>;
angular.module('<%= moduleName %>'<% if (createModule) { %>, []<% } %>)<% _.forEach(constants, function (constant) { %>
.<%= type %>('<%= constant.name %>', <%= constant.value %>)<% }); %>;
4 changes: 2 additions & 2 deletions test/mocks/output_1.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("one", "two");
angular.module('gulp-ng-config', [])
.constant('one', 'two');
6 changes: 3 additions & 3 deletions test/mocks/output_10.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
angular.module("gulp-ng-config", [])
.constant("environmentA", {"one":{"two":"three"}})
.constant("environmentB", {"four":{"five":"six"}});
angular.module('gulp-ng-config', [])
.constant('environmentA', {'one':{'two':'three'}})
.constant('environmentB', {'four':{'five':'six'}});
6 changes: 3 additions & 3 deletions test/mocks/output_11.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"})
.constant("constant", "value");
angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'})
.constant('constant', 'value');
6 changes: 3 additions & 3 deletions test/mocks/output_12.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module("gulp-ng-config", [])
.constant("one", {
"two": "three"
angular.module('gulp-ng-config', [])
.constant('one', {
'two': 'three'
});
6 changes: 3 additions & 3 deletions test/mocks/output_13.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module("gulp-ng-config", [])
.constant("one", {
"two": "three"
angular.module('gulp-ng-config', [])
.constant('one', {
'two': 'three'
});
4 changes: 2 additions & 2 deletions test/mocks/output_14.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"});
angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'});
4 changes: 2 additions & 2 deletions test/mocks/output_15.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"});
angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'});
4 changes: 2 additions & 2 deletions test/mocks/output_16.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.value("one", {"two":"three"});
angular.module('gulp-ng-config', [])
.value('one', {'two':'three'});
4 changes: 2 additions & 2 deletions test/mocks/output_17.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import angular from 'angular';
export default angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"});
export default angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'});
4 changes: 2 additions & 2 deletions test/mocks/output_2.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"});
angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'});
4 changes: 2 additions & 2 deletions test/mocks/output_3.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("one", {"two":"four"});
angular.module('gulp-ng-config', [])
.constant('one', {'two':'four'});
4 changes: 2 additions & 2 deletions test/mocks/output_4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("one", {"two":"three","three":"four"});
angular.module('gulp-ng-config', [])
.constant('one', {'two':'three','three':'four'});
4 changes: 2 additions & 2 deletions test/mocks/output_5.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config")
.constant("one", {"two":"three"});
angular.module('gulp-ng-config')
.constant('one', {'two':'three'});
6 changes: 3 additions & 3 deletions test/mocks/output_6.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function () {
return angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"});
(function () {
return angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'});

})();
4 changes: 2 additions & 2 deletions test/mocks/output_7.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['angular', function () {
return angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"});
return angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'});
}]);
4 changes: 2 additions & 2 deletions test/mocks/output_8.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("one", {"two":"three"});
angular.module('gulp-ng-config', [])
.constant('one', {'two':'three'});
4 changes: 2 additions & 2 deletions test/mocks/output_9.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("gulp-ng-config", [])
.constant("four", {"five":"six"});
angular.module('gulp-ng-config', [])
.constant('four', {'five':'six'});

0 comments on commit 17490cb

Please sign in to comment.